1{ stdenv, buildPythonPackage, pythonOlder, fetchPypi, attrs, hypothesis, py
2, setuptools_scm, setuptools, six, pluggy, funcsigs, isPy3k, more-itertools
3, atomicwrites, mock, writeText, pathlib2, wcwidth, packaging, isPyPy
4}:
5buildPythonPackage rec {
6 version = "4.6.11";
7 pname = "pytest";
8
9 src = fetchPypi {
10 inherit pname version;
11 sha256 = "50fa82392f2120cc3ec2ca0a75ee615be4c479e66669789771f1758332be4353";
12 };
13
14 checkInputs = [ hypothesis mock ];
15 buildInputs = [ setuptools_scm ];
16 propagatedBuildInputs = [ attrs py setuptools six pluggy more-itertools atomicwrites wcwidth packaging ]
17 ++ stdenv.lib.optionals (!isPy3k) [ funcsigs ]
18 ++ stdenv.lib.optionals (pythonOlder "3.6") [ pathlib2 ];
19
20 doCheck = !isPyPy; # https://github.com/pytest-dev/pytest/issues/3460
21 checkPhase = ''
22 runHook preCheck
23
24 # don't test bash builtins
25 rm testing/test_argcomplete.py
26
27 # determinism - this test writes non deterministic bytecode
28 rm -rf testing/test_assertrewrite.py
29
30 PYTHONDONTWRITEBYTECODE=1 $out/bin/py.test -x testing/ -k "not test_collect_pyargs_with_testpaths"
31 runHook postCheck
32 '';
33
34 # Remove .pytest_cache when using py.test in a Nix build
35 setupHook = writeText "pytest-hook" ''
36 pytestcachePhase() {
37 find $out -name .pytest_cache -type d -exec rm -rf {} +
38 }
39
40 preDistPhases+=" pytestcachePhase"
41 '';
42
43 meta = with stdenv.lib; {
44 homepage = "https://docs.pytest.org";
45 description = "Framework for writing tests";
46 maintainers = with maintainers; [ domenkozar lovek323 madjar lsix ];
47 license = licenses.mit;
48 platforms = platforms.unix;
49 };
50}