Something went wrong. Try again.
Nix Packages collection & NixOS github.com/NixOS/nixpkgs
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141{ lib, buildPythonPackage, isPyPy, fetchFromGitHub, attrs, gitMinimal, pexpect, doCheck ? true, pytestCheckHook, pytest-xdist, rustPlatform, sortedcontainers, syrupy, tzdata,}:
buildPythonPackage (finalAttrs: { pname = "hypothesis"; version = "6.168.1"; pyproject = true;
__structuredAttrs = true;
src = fetchFromGitHub { owner = "HypothesisWorks"; repo = "hypothesis"; tag = "v${finalAttrs.version}"; hash = "sha256-cTwSfuEDzUJIZgBCrnq3kHpi1IFBJpHl9uoMq+5pUxI="; };
sourceRoot = "${finalAttrs.src.name}/hypothesis";
cargoRoot = "rust"; cargoDeps = rustPlatform.fetchCargoVendor { inherit (finalAttrs) pname version src sourceRoot cargoRoot ; hash = "sha256-oYVv711H7B5jjtDiAMZUUOwi1VEszvC0qAGfaSJnO/g="; };
# I tried to package sphinx-selective-exclude, but it throws # error about "module 'sphinx' has no attribute 'directives'". # # It probably has to do with monkey-patching internals of Sphinx. # On bright side, this extension does not introduces new commands, # only changes "::only" command, so we probably okay with stock # implementation. # # I wonder how upstream of "hypothesis" builds documentation. postPatch = '' sed -i -e '/sphinx_selective_exclude.eager_only/ d' docs/conf.py '';
nativeBuildInputs = [ rustPlatform.cargoSetupHook ];
build-system = [ rustPlatform.maturinBuildHook ];
dependencies = [ attrs sortedcontainers ];
nativeCheckInputs = [ gitMinimal pexpect pytest-xdist pytestCheckHook (syrupy.overridePythonAttrs { doCheck = false; }) ] ++ lib.optionals isPyPy [ tzdata ];
inherit doCheck;
# tox.ini changes how pytest runs and breaks it. # Activate the CI profile (similar to setupHook below) # by setting HYPOTHESIS_PROFILE [1]. # # [1]: https://github.com/HypothesisWorks/hypothesis/blob/hypothesis-python-6.130.9/hypothesis-python/tests/common/setup.py#L78 preCheck = '' rm tox.ini export HYPOTHESIS_PROFILE=ci export TMPDIR=$(mktemp -d) '';
pytestFlags = [ "-p no:cacheprovider" ];
enabledTestPaths = [ "tests/cover" ];
# Hypothesis by default activates several "Health Checks", including one that fires if the builder is "too slow". # This check is disabled [1] if Hypothesis detects a CI environment, i.e. either `CI` or `TF_BUILD` is defined [2]. # We set `CI=1` here using a setup hook to avoid spurious failures [3]. # # Example error message for reference: # hypothesis.errors.FailedHealthCheck: Data generation is extremely slow: Only produced 2 valid examples in 1.28 seconds (1 invalid ones and 0 exceeded maximum size). Try decreasing size of the data you're generating (with e.g. max_size or max_leaves parameters). # # [1]: https://github.com/HypothesisWorks/hypothesis/blob/hypothesis-python-6.130.9/hypothesis-python/src/hypothesis/_settings.py#L816-L828 # [2]: https://github.com/HypothesisWorks/hypothesis/blob/hypothesis-python-6.130.9/hypothesis-python/src/hypothesis/_settings.py#L756 # [3]: https://github.com/NixOS/nixpkgs/issues/393637 setupHook = ./setup-hook.sh;
disabledTests = [ # fail when using CI profile "test_given_does_not_pollute_state" "test_find_does_not_pollute_state" "test_does_print_on_reuse_from_database" "test_prints_seed_only_on_healthcheck" "test_prints_seed_on_very_slow_shrinking" "test_regex_output_should_print_as_string" ] ++ lib.optionals isPyPy [ # hypothesis.errors.Unsatisfiable: Could not find any examples from datetimes(min_value=datetime.datetime(2003, 1, 1, 0, 0), max_value=datetime.datetime(2005, 12, 31, 23, 59, 59, 999999)) that satisfied lambda x: x.month == 2 and x.day == 29 "test_bordering_on_a_leap_year" ];
pythonImportsCheck = [ "hypothesis" ];
meta = { description = "Library for property based testing"; mainProgram = "hypothesis"; homepage = "https://github.com/HypothesisWorks/hypothesis"; changelog = "https://hypothesis.readthedocs.io/en/latest/changes.html#v${ lib.replaceStrings [ "." ] [ "-" ] finalAttrs.version }"; license = lib.licenses.mpl20; maintainers = [ lib.maintainers.fliegendewurst ]; };})