21 # optional-dependencies
30 buildPythonPackage rec {
36 inherit pname version;
37 hash = "sha256-cLmBB71kgwinlSsG5sqaULxmC+IY1TwlfMH8lP2hAYE=";
50 propagatedBuildInputs =
56 ++ lib.optionals (pythonOlder "3.11") [
61 optional-dependencies = {
76 cp -R testing $testout/testing
80 passthru.tests.pytest = callPackage ./tests.nix { };
82 # Remove .pytest_cache when using py.test in a Nix build
83 setupHook = writeText "pytest-hook" ''
85 find $out -name .pytest_cache -type d -exec rm -rf {} +
87 appendToVar preDistPhases pytestcachePhase
89 # pytest generates it's own bytecode files to improve assertion messages.
90 # These files similar to cpython's bytecode files but are never laoded
91 # by python interpreter directly. We remove them for a few reasons:
92 # - files are non-deterministic: https://github.com/NixOS/nixpkgs/issues/139292
93 # (file headers are generatedt by pytest directly and contain timestamps)
94 # - files are not needed after tests are finished
95 pytestRemoveBytecodePhase () {
96 # suffix is defined at:
97 # https://github.com/pytest-dev/pytest/blob/7.2.1/src/_pytest/assertion/rewrite.py#L51-L53
98 find $out -name "*-pytest-*.py[co]" -delete
100 appendToVar preDistPhases pytestRemoveBytecodePhase
103 pythonImportsCheck = [ "pytest" ];
106 description = "Framework for writing tests";
107 homepage = "https://docs.pytest.org";
108 changelog = "https://github.com/pytest-dev/pytest/releases/tag/${version}";
109 maintainers = with maintainers; [
115 license = licenses.mit;