From 942d0482e31ec6fb6383c7b976cbba3c7db2242c Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Sat, 16 Sep 2023 16:12:13 +0300 Subject: [PATCH] python3.pkgs.msprime: use pytestCheckHook Instead of manually specifying the disabled tests and test paths in `checkPhase`, use the pytestCheckHook for that, and avoid the issue described at https://github.com/NixOS/nixpkgs/issues/255262 by removing the source directory. --- .../python-modules/msprime/default.nix | 42 +++++++++---------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/pkgs/development/python-modules/msprime/default.nix b/pkgs/development/python-modules/msprime/default.nix index f4b3a2eb70c6c0..008ce7f2711e43 100644 --- a/pkgs/development/python-modules/msprime/default.nix +++ b/pkgs/development/python-modules/msprime/default.nix @@ -10,7 +10,7 @@ , newick , tskit , demes -, pytest +, pytestCheckHook , pytest-xdist , scipy }: @@ -45,33 +45,29 @@ buildPythonPackage rec { ]; nativeCheckInputs = [ - pytest + pytestCheckHook pytest-xdist scipy ]; + disabledTests = [ + "tests/test_ancestry.py::TestSimulator::test_debug_logging" + "tests/test_ancestry.py::TestSimulator::test_debug_logging_dtw" + ]; + disabledTestPaths = [ + "tests/test_demography.py" + "tests/test_algorithms.py" + "tests/test_provenance.py" + "tests/test_dict_encoding.py" + ]; - checkPhase = '' - runHook preCheck - - # avoid adding the current directory to sys.path - # https://docs.pytest.org/en/7.1.x/explanation/pythonpath.html#invoking-pytest-versus-python-m-pytest - # need pythonPackages.stdpopsim - # need pythonPackages.bintrees - # need pythonPachages.python_jsonschema_objects - # ModuleNotFoundError: No module named 'lwt_interface.dict_encoding_testlib' - # fails for python311 - # fails for python311 - pytest -v --import-mode append \ - --ignore=tests/test_demography.py \ - --ignore=tests/test_algorithms.py \ - --ignore=tests/test_provenance.py \ - --ignore=tests/test_dict_encoding.py \ - --deselect=tests/test_ancestry.py::TestSimulator::test_debug_logging \ - --deselect=tests/test_ancestry.py::TestSimulator::test_debug_logging_dtwf - - runHook postCheck + # `python -m pytest` puts $PWD in sys.path, which causes the extension + # modules imported as `msprime._msprime` to be unavailable, failing the + # tests. This deletes the `msprime` folder such that only what's installed in + # $out is used for the imports. See also discussion at: + # https://github.com/NixOS/nixpkgs/issues/255262 + preCheck = '' + rm -r msprime ''; - pythonImportsCheck = [ "msprime" ];