3
0
Fork 0
forked from mirrors/nixpkgs

python3Packages.pytest: extract test into passthru

Necessary To escape infinite recursion with hypothesis.
This commit is contained in:
Martin Weinelt 2022-07-15 00:13:44 +02:00
parent f5a5276172
commit fe12670469
3 changed files with 53 additions and 32 deletions

View file

@ -1,5 +1,6 @@
{ lib
, buildPythonPackage
, callPackage
, pythonOlder
, fetchPypi
, isPyPy
@ -15,10 +16,6 @@
, pluggy
, py
, tomli
# tests
, hypothesis
, pygments
}:
buildPythonPackage rec {
@ -31,6 +28,11 @@ buildPythonPackage rec {
sha256 = "sha256-oGoEJUU4ZKJwvEXnH3gzMKdCje+0Iw+15qcx/eBuzUU=";
};
outputs = [
"out"
"testout"
];
nativeBuildInputs = [
setuptools-scm
];
@ -44,30 +46,14 @@ buildPythonPackage rec {
tomli
];
checkInputs = [
hypothesis
pygments
];
doCheck = !isPyPy; # https://github.com/pytest-dev/pytest/issues/3460
# Ignored file https://github.com/pytest-dev/pytest/pull/5605#issuecomment-522243929
# test_missing_required_plugins will emit deprecation warning which is treated as error
checkPhase = ''
runHook preCheck
$out/bin/py.test -x testing/ \
--ignore=testing/test_junitxml.py \
--ignore=testing/test_argcomplete.py \
-k "not test_collect_pyargs_with_testpaths and not test_missing_required_plugins"
# tests leave behind unreproducible pytest binaries in the output directory, remove:
find $out/lib -name "*-pytest-${version}.pyc" -delete
# specifically testing/test_assertion.py and testing/test_assertrewrite.py leave behind those:
find $out/lib -name "*opt-2.pyc" -delete
runHook postCheck
postInstall = ''
mkdir $testout
cp -R testing $testout/testing
'';
doCheck = false;
passthru.tests.pytest = callPackage ./tests.nix { };
# Remove .pytest_cache when using py.test in a Nix build
setupHook = writeText "pytest-hook" ''
pytestcachePhase() {

View file

@ -0,0 +1,40 @@
{ buildPythonPackage
, isPyPy
, pytest
, hypothesis
, pygments
}:
buildPythonPackage rec {
pname = "pytest-tests";
inherit (pytest) version;
src = pytest.testout;
dontBuild = true;
dontInstall = true;
checkInputs = [
hypothesis
pygments
];
doCheck = !isPyPy; # https://github.com/pytest-dev/pytest/issues/3460
# Ignored file https://github.com/pytest-dev/pytest/pull/5605#issuecomment-522243929
# test_missing_required_plugins will emit deprecation warning which is treated as error
checkPhase = ''
runHook preCheck
${pytest.out}/bin/py.test -x testing/ \
--ignore=testing/test_junitxml.py \
--ignore=testing/test_argcomplete.py \
-k "not test_collect_pyargs_with_testpaths and not test_missing_required_plugins"
# tests leave behind unreproducible pytest binaries in the output directory, remove:
find $out/lib -name "*-pytest-${version}.pyc" -delete
# specifically testing/test_assertion.py and testing/test_assertrewrite.py leave behind those:
find $out/lib -name "*opt-2.pyc" -delete
runHook postCheck
'';
}

View file

@ -8294,12 +8294,7 @@ in {
pytesseract = callPackage ../development/python-modules/pytesseract { };
pytest = callPackage ../development/python-modules/pytest {
# hypothesis tests require pytest that causes dependency cycle
hypothesis = self.hypothesis.override {
doCheck = false;
};
};
pytest = callPackage ../development/python-modules/pytest { };
pytest-aio = callPackage ../development/python-modules/pytest-aio { };