22 buildPythonPackage rec {
28 inherit pname version;
29 hash = "sha256-2YnRNpgt5OOynavMg4rVgcZOjtUsEfvobd69naCBjNU=";
42 propagatedBuildInputs = [
49 ] ++ lib.optionals (pythonOlder "3.11") [
55 cp -R testing $testout/testing
59 passthru.tests.pytest = callPackage ./tests.nix { };
61 # Remove .pytest_cache when using py.test in a Nix build
62 setupHook = writeText "pytest-hook" ''
64 find $out -name .pytest_cache -type d -exec rm -rf {} +
66 preDistPhases+=" pytestcachePhase"
68 # pytest generates it's own bytecode files to improve assertion messages.
69 # These files similar to cpython's bytecode files but are never laoded
70 # by python interpreter directly. We remove them for a few reasons:
71 # - files are non-deterministic: https://github.com/NixOS/nixpkgs/issues/139292
72 # (file headers are generatedt by pytest directly and contain timestamps)
73 # - files are not needed after tests are finished
74 pytestRemoveBytecodePhase () {
75 # suffix is defined at:
76 # https://github.com/pytest-dev/pytest/blob/7.2.1/src/_pytest/assertion/rewrite.py#L51-L53
77 find $out -name "*-pytest-*.py[co]" -delete
79 preDistPhases+=" pytestRemoveBytecodePhase"
82 pythonImportsCheck = [
87 description = "Framework for writing tests";
88 homepage = "https://docs.pytest.org";
89 changelog = "https://github.com/pytest-dev/pytest/releases/tag/${version}";
90 maintainers = with maintainers; [ domenkozar lovek323 madjar lsix ];
91 license = licenses.mit;