python3Packages.hypothesis: fix downstream flaky test failures
This commit is contained in:
@@ -27,7 +27,7 @@ buildPythonPackage rec {
|
||||
version = "6.130.12";
|
||||
pyproject = true;
|
||||
|
||||
disabled = pythonOlder "3.7";
|
||||
disabled = pythonOlder "3.9";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "HypothesisWorks";
|
||||
@@ -66,20 +66,40 @@ buildPythonPackage rec {
|
||||
|
||||
inherit doCheck;
|
||||
|
||||
# This file changes how pytest runs and breaks it
|
||||
# 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
|
||||
'';
|
||||
|
||||
pytestFlagsArray = [ "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 =
|
||||
[
|
||||
# racy, fails to find a file sometimes
|
||||
"test_recreate_charmap"
|
||||
"test_uses_cached_charmap"
|
||||
# fails if builder is too slow
|
||||
"test_can_run_with_no_db"
|
||||
# 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"
|
||||
# calls script with the naked interpreter
|
||||
"test_constants_from_running_file"
|
||||
]
|
||||
@@ -122,14 +142,16 @@ buildPythonPackage rec {
|
||||
};
|
||||
};
|
||||
|
||||
meta = with lib; {
|
||||
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 [ "." ] [ "-" ] version
|
||||
}";
|
||||
license = licenses.mpl20;
|
||||
maintainers = [ ];
|
||||
license = lib.licenses.mpl20;
|
||||
maintainers = [
|
||||
lib.maintainers.fliegendewurst
|
||||
];
|
||||
};
|
||||
}
|
||||
|
||||
5
pkgs/development/python-modules/hypothesis/setup-hook.sh
Normal file
5
pkgs/development/python-modules/hypothesis/setup-hook.sh
Normal file
@@ -0,0 +1,5 @@
|
||||
hypothesisActivateProfileForCI() {
|
||||
export CI=1
|
||||
}
|
||||
|
||||
postHooks+=(hypothesisActivateProfileForCI)
|
||||
Reference in New Issue
Block a user