Merge pull request #119126 from fabaff/pycomfoconnect
[NixPkgs.git] / pkgs / development / python-modules / pytest / default.nix
blob579cfe1271f3a4b49fe28817d522d482c9944cbb
1 { lib, buildPythonPackage, pythonOlder, fetchPypi, isPy3k, isPyPy
2 , atomicwrites
3 , attrs
4 , hypothesis
5 , iniconfig
6 , more-itertools
7 , packaging
8 , pathlib2
9 , pluggy
10 , py
11 , pygments
12 , setuptools
13 , setuptools-scm
14 , six
15 , toml
16 , wcwidth
17 , writeText
20 buildPythonPackage rec {
21   pname = "pytest";
22   version = "6.2.2";
23   disabled = !isPy3k;
25   src = fetchPypi {
26     inherit pname version;
27     sha256 = "sha256-nR7fnn0LhNcuo9vN/SKzX7VDpejypgCS3VeJNr9j1/k=";
28   };
30   nativeBuildInputs = [ setuptools-scm ];
32   propagatedBuildInputs = [
33     atomicwrites
34     attrs
35     iniconfig
36     more-itertools
37     packaging
38     pluggy
39     py
40     setuptools
41     six
42     toml
43     wcwidth
44   ] ++ lib.optionals (pythonOlder "3.6") [ pathlib2 ];
46   checkInputs = [
47     hypothesis
48     pygments
49   ];
51   doCheck = !isPyPy; # https://github.com/pytest-dev/pytest/issues/3460
53   preCheck = ''
54     # don't test bash builtins
55     rm testing/test_argcomplete.py
56   '';
58   # Ignored file https://github.com/pytest-dev/pytest/pull/5605#issuecomment-522243929
59   checkPhase = ''
60     runHook preCheck
61     $out/bin/py.test -x testing/ -k "not test_collect_pyargs_with_testpaths" --ignore=testing/test_junitxml.py
63     # tests leave behind unreproducible pytest binaries in the output directory, remove:
64     find $out/lib -name "*-pytest-${version}.pyc" -delete
65     # specifically testing/test_assertion.py and testing/test_assertrewrite.py leave behind those:
66     find $out/lib -name "*opt-2.pyc" -delete
68     runHook postCheck
69   '';
71   # Remove .pytest_cache when using py.test in a Nix build
72   setupHook = writeText "pytest-hook" ''
73     pytestcachePhase() {
74         find $out -name .pytest_cache -type d -exec rm -rf {} +
75     }
76     preDistPhases+=" pytestcachePhase"
77   '';
79   pythonImportsCheck = [
80     "pytest"
81   ];
83   meta = with lib; {
84     description = "Framework for writing tests";
85     homepage = "https://docs.pytest.org";
86     changelog = "https://github.com/pytest-dev/pytest/releases/tag/${version}";
87     maintainers = with maintainers; [ domenkozar lovek323 madjar lsix ];
88     license = licenses.mit;
89   };