From 3d568360e73d138efc3360b8849b5698e7dfba3d Mon Sep 17 00:00:00 2001 From: Luke Granger-Brown Date: Sat, 12 Jun 2021 13:26:14 +0000 Subject: [PATCH] python3Packages.attrs: separate test run into a separate tests attribute. This resolves a circular dependency issue between pytest and attrs, by instead building a separate output that _just_ contains the tests from the original package, which is then consumed by a separate tests derivation. The downside of this approach is that these tests will not be run on Hydra. They're not being run on Hydra at the moment, either, since doCheck is false. --- .../python-modules/attrs/default.nix | 27 ++++++++++++------- .../python-modules/attrs/tests.nix | 21 +++++++++++++++ 2 files changed, 39 insertions(+), 9 deletions(-) create mode 100644 pkgs/development/python-modules/attrs/tests.nix diff --git a/pkgs/development/python-modules/attrs/default.nix b/pkgs/development/python-modules/attrs/default.nix index 9ea1714ca595..08730e3d689e 100644 --- a/pkgs/development/python-modules/attrs/default.nix +++ b/pkgs/development/python-modules/attrs/default.nix @@ -1,5 +1,8 @@ -{ lib, stdenv, buildPythonPackage, fetchPypi, pytest, hypothesis, zope_interface -, pympler, coverage, six, clang }: +{ lib +, callPackage +, buildPythonPackage +, fetchPypi +}: buildPythonPackage rec { pname = "attrs"; @@ -10,18 +13,24 @@ buildPythonPackage rec { sha256 = "ef6aaac3ca6cd92904cdd0d83f629a15f18053ec84e6432106f7a4d04ae4f5fb"; }; - # macOS needs clang for testing - checkInputs = [ - pytest hypothesis zope_interface pympler coverage six - ] ++ lib.optionals (stdenv.isDarwin) [ clang ]; + outputs = [ "out" "testout" ]; - checkPhase = '' - py.test + postInstall = '' + # Install tests as the tests output. + mkdir $testout + cp -R tests $testout/tests ''; - # To prevent infinite recursion with pytest + pythonImportsCheck = [ "attr" ]; + + # pytest depends on attrs, so we can't do this out-of-the-box. + # Instead, we do this as a passthru.tests test. doCheck = false; + passthru.tests = { + pytest = callPackage ./tests.nix { }; + }; + meta = with lib; { description = "Python attributes without boilerplate"; homepage = "https://github.com/hynek/attrs"; diff --git a/pkgs/development/python-modules/attrs/tests.nix b/pkgs/development/python-modules/attrs/tests.nix new file mode 100644 index 000000000000..c9fae9e0228c --- /dev/null +++ b/pkgs/development/python-modules/attrs/tests.nix @@ -0,0 +1,21 @@ +{ buildPythonPackage +, pytestCheckHook +, attrs +, hypothesis +}: + +buildPythonPackage { + pname = "attrs-tests"; + inherit (attrs) version; + + srcs = attrs.testout; + + dontBuild = true; + dontInstall = true; + + checkInputs = [ + attrs + hypothesis + pytestCheckHook + ]; +}