From b3febfb8505e4d1c990c85b41b288b4cc0feba55 Mon Sep 17 00:00:00 2001 From: Frederik Rietdijk Date: Thu, 14 Feb 2019 11:07:19 +0100 Subject: [PATCH] python.pkgs.pytest_3: keep older version because not all test suites are compatible with 4 yet. --- .../python-modules/apipkg/default.nix | 6 +-- .../python-modules/chardet/default.nix | 4 +- .../python-modules/execnet/default.nix | 7 ++- .../python-modules/pytest/3.10.nix | 47 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 6 +++ 5 files changed, 63 insertions(+), 7 deletions(-) create mode 100644 pkgs/development/python-modules/pytest/3.10.nix diff --git a/pkgs/development/python-modules/apipkg/default.nix b/pkgs/development/python-modules/apipkg/default.nix index 8e6fc668204..bd535a972d1 100644 --- a/pkgs/development/python-modules/apipkg/default.nix +++ b/pkgs/development/python-modules/apipkg/default.nix @@ -1,5 +1,5 @@ { stdenv, buildPythonPackage, fetchPypi -, pytest, setuptools_scm }: +, pytest_3, setuptools_scm }: buildPythonPackage rec { pname = "apipkg"; @@ -10,8 +10,8 @@ buildPythonPackage rec { sha256 = "37228cda29411948b422fae072f57e31d3396d2ee1c9783775980ee9c9990af6"; }; - buildInputs = [ setuptools_scm ]; - checkInputs = [ pytest ]; + nativeBuildInputs = [ setuptools_scm ]; + checkInputs = [ pytest_3 ]; checkPhase = '' py.test diff --git a/pkgs/development/python-modules/chardet/default.nix b/pkgs/development/python-modules/chardet/default.nix index 1f452fb461a..3509a646993 100644 --- a/pkgs/development/python-modules/chardet/default.nix +++ b/pkgs/development/python-modules/chardet/default.nix @@ -1,5 +1,5 @@ { stdenv, buildPythonPackage, fetchPypi -, pytest, pytestrunner, hypothesis }: +, pytest_3, pytestrunner, hypothesis }: buildPythonPackage rec { pname = "chardet"; @@ -10,7 +10,7 @@ buildPythonPackage rec { sha256 = "1bpalpia6r5x1kknbk11p1fzph56fmmnp405ds8icksd3knr5aw4"; }; - checkInputs = [ pytest pytestrunner hypothesis ]; + checkInputs = [ pytest_3 pytestrunner hypothesis ]; meta = with stdenv.lib; { homepage = https://github.com/chardet/chardet; diff --git a/pkgs/development/python-modules/execnet/default.nix b/pkgs/development/python-modules/execnet/default.nix index 6f97a2cb6bf..df78bff6f1d 100644 --- a/pkgs/development/python-modules/execnet/default.nix +++ b/pkgs/development/python-modules/execnet/default.nix @@ -1,7 +1,7 @@ { stdenv , buildPythonPackage , fetchPypi -, pytest +, pytest_3 , setuptools_scm , apipkg }: @@ -15,7 +15,7 @@ buildPythonPackage rec { sha256 = "a7a84d5fa07a089186a329528f127c9d73b9de57f1a1131b82bb5320ee651f6a"; }; - checkInputs = [ pytest ]; + checkInputs = [ pytest_3 ]; nativeBuildInputs = [ setuptools_scm ]; propagatedBuildInputs = [ apipkg ]; @@ -31,6 +31,9 @@ buildPythonPackage rec { py.test testing ''; + # not yet compatible with pytest 4 + doCheck = false; + __darwinAllowLocalNetworking = true; meta = with stdenv.lib; { diff --git a/pkgs/development/python-modules/pytest/3.10.nix b/pkgs/development/python-modules/pytest/3.10.nix new file mode 100644 index 00000000000..f24cab8af1c --- /dev/null +++ b/pkgs/development/python-modules/pytest/3.10.nix @@ -0,0 +1,47 @@ +{ stdenv, buildPythonPackage, pythonOlder, fetchPypi, attrs, hypothesis, py +, setuptools_scm, setuptools, six, pluggy, funcsigs, isPy3k, more-itertools +, atomicwrites, mock, writeText, pathlib2 +}: +buildPythonPackage rec { + version = "3.10.1"; + pname = "pytest"; + + preCheck = '' + # don't test bash builtins + rm testing/test_argcomplete.py + ''; + + src = fetchPypi { + inherit pname version; + sha256 = "e246cf173c01169b9617fc07264b7b1316e78d7a650055235d6d897bc80d9660"; + }; + + checkInputs = [ hypothesis mock ]; + buildInputs = [ setuptools_scm ]; + propagatedBuildInputs = [ attrs py setuptools six pluggy more-itertools atomicwrites] + ++ stdenv.lib.optionals (!isPy3k) [ funcsigs ] + ++ stdenv.lib.optionals (pythonOlder "3.6") [ pathlib2 ]; + + checkPhase = '' + runHook preCheck + $out/bin/py.test -x testing/ -k "not test_raises_exception_looks_iterable" + runHook postCheck + ''; + + # Remove .pytest_cache when using py.test in a Nix build + setupHook = writeText "pytest-hook" '' + pytestcachePhase() { + find $out -name .pytest_cache -type d -exec rm -rf {} + + } + + preDistPhases+=" pytestcachePhase" + ''; + + meta = with stdenv.lib; { + homepage = https://docs.pytest.org; + description = "Framework for writing tests"; + maintainers = with maintainers; [ domenkozar lovek323 madjar lsix ]; + license = licenses.mit; + platforms = platforms.unix; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index e00567e8020..30eba87155e 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -1500,6 +1500,12 @@ in { hypothesis = self.hypothesis.override { doCheck = false; }; }; + # Keep 3 because many test suites are not yet compatible with Pytest 4. + pytest_3 = callPackage ../development/python-modules/pytest/3.10.nix { + # hypothesis tests require pytest that causes dependency cycle + hypothesis = self.hypothesis.override { doCheck = false; }; + }; + pytest-httpbin = callPackage ../development/python-modules/pytest-httpbin { }; pytest-asyncio = callPackage ../development/python-modules/pytest-asyncio { };