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
18}:
19
20buildPythonPackage rec {
21 pname = "pytest";
22 version = "6.2.3";
23 disabled = !isPy3k;
24
25 src = fetchPypi {
26 inherit pname version;
27 sha256 = "0d5nx7xqr9khagbvg6ac2cjjvcxrvvjp0chwim4z7w2ddsj3h4k7";
28 };
29
30 nativeBuildInputs = [ setuptools-scm ];
31
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 ];
45
46 checkInputs = [
47 hypothesis
48 pygments
49 ];
50
51 doCheck = !isPyPy; # https://github.com/pytest-dev/pytest/issues/3460
52
53 preCheck = ''
54 # don't test bash builtins
55 rm testing/test_argcomplete.py
56 '';
57
58 # Ignored file https://github.com/pytest-dev/pytest/pull/5605#issuecomment-522243929
59 # test_missing_required_plugins will emit deprecation warning which is treated as error
60 checkPhase = ''
61 runHook preCheck
62 $out/bin/py.test -x testing/ \
63 --ignore=testing/test_junitxml.py \
64 -k "not test_collect_pyargs_with_testpaths and not test_missing_required_plugins"
65
66 # tests leave behind unreproducible pytest binaries in the output directory, remove:
67 find $out/lib -name "*-pytest-${version}.pyc" -delete
68 # specifically testing/test_assertion.py and testing/test_assertrewrite.py leave behind those:
69 find $out/lib -name "*opt-2.pyc" -delete
70
71 runHook postCheck
72 '';
73
74 # Remove .pytest_cache when using py.test in a Nix build
75 setupHook = writeText "pytest-hook" ''
76 pytestcachePhase() {
77 find $out -name .pytest_cache -type d -exec rm -rf {} +
78 }
79 preDistPhases+=" pytestcachePhase"
80 '';
81
82 pythonImportsCheck = [
83 "pytest"
84 ];
85
86 meta = with lib; {
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;
92 };
93}