Skip to content

Commit

Permalink
python3.pkgs.msprime: use pytestCheckHook
Browse files Browse the repository at this point in the history
Instead of manually specifying the disabled tests and test paths in
`checkPhase`, use the pytestCheckHook for that, and avoid the issue
described at NixOS#255262 by removing
the source directory.
  • Loading branch information
doronbehar committed Sep 16, 2023
1 parent f1a88c0 commit 942d048
Showing 1 changed file with 19 additions and 23 deletions.
42 changes: 19 additions & 23 deletions pkgs/development/python-modules/msprime/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
, newick
, tskit
, demes
, pytest
, pytestCheckHook
, pytest-xdist
, scipy
}:
Expand Down Expand Up @@ -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"
];
Expand Down

0 comments on commit 942d048

Please sign in to comment.