Loading pkgs/development/interpreters/python/hooks/default.nix +48 −1 Original line number Diff line number Diff line Loading @@ -146,13 +146,60 @@ in }; pytestCheckHook = callPackage ( { makePythonHook, pytest }: { makePythonHook, pytest, # For package tests testers, objprint, }: makePythonHook { name = "pytest-check-hook"; propagatedBuildInputs = [ pytest ]; substitutions = { inherit pythonCheckInterpreter; }; passthru = { tests = { basic = objprint.overridePythonAttrs (previousPythonAttrs: { pname = "test-pytestCheckHook-basic-${previousPythonAttrs.pname}"; }); disabledTests = objprint.overridePythonAttrs (previousPythonAttrs: { pname = "test-pytestCheckHook-disabledTests-${previousPythonAttrs.pname}"; disabledTests = [ "test_print" ] ++ previousPythonAttrs.disabledTests or [ ]; }); disabledTestPaths = objprint.overridePythonAttrs (previousPythonAttrs: { pname = "test-pytestCheckHook-disabledTestPaths-${previousPythonAttrs.pname}"; disabledTestPaths = [ "tests/test_basic.py" ] ++ previousPythonAttrs.disabledTestPaths or [ ]; }); disabledTestPaths-nonexistent = testers.testBuildFailure ( objprint.overridePythonAttrs (previousPythonAttrs: { pname = "test-pytestCheckHook-disabledTestPaths-nonexistent-${previousPythonAttrs.pname}"; disabledTestPaths = [ "tests/test_foo.py" ] ++ previousPythonAttrs.disabledTestPaths or [ ]; }) ); disabledTestPaths-glob = objprint.overridePythonAttrs (previousPythonAttrs: { pname = "test-pytestCheckHook-disabledTestPaths-glob-${previousPythonAttrs.pname}"; disabledTestPaths = [ "tests/test_obj*.py" ] ++ previousPythonAttrs.disabledTestPaths or [ ]; }); disabledTestPaths-glob-nonexistent = testers.testBuildFailure ( objprint.overridePythonAttrs (previousPythonAttrs: { pname = "test-pytestCheckHook-disabledTestPaths-glob-nonexistent-${previousPythonAttrs.pname}"; disabledTestPaths = [ "tests/test_foo*.py" ] ++ previousPythonAttrs.disabledTestPaths or [ ]; }) ); }; }; } ./pytest-check-hook.sh ) { }; Loading pkgs/development/interpreters/python/hooks/pytest-check-hook.sh +1 −2 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ function pytestCheckPhase() { concatTo _pathsArray disabledTestPaths for path in "${_pathsArray[@]}"; do # Check if every path glob matches at least one path @pythonCheckInterpreter@ <(cat <<EOF @pythonCheckInterpreter@ - "$path" <<EOF import glob import sys path_glob=sys.argv[1] Loading @@ -27,7 +27,6 @@ if not len(path_glob): if next(glob.iglob(path_glob), None) is None: sys.exit('Disabled tests path glob "{}" does not match any paths. Aborting'.format(path_glob)) EOF ) "$path" flagsArray+=("--ignore-glob=$path") done Loading Loading
pkgs/development/interpreters/python/hooks/default.nix +48 −1 Original line number Diff line number Diff line Loading @@ -146,13 +146,60 @@ in }; pytestCheckHook = callPackage ( { makePythonHook, pytest }: { makePythonHook, pytest, # For package tests testers, objprint, }: makePythonHook { name = "pytest-check-hook"; propagatedBuildInputs = [ pytest ]; substitutions = { inherit pythonCheckInterpreter; }; passthru = { tests = { basic = objprint.overridePythonAttrs (previousPythonAttrs: { pname = "test-pytestCheckHook-basic-${previousPythonAttrs.pname}"; }); disabledTests = objprint.overridePythonAttrs (previousPythonAttrs: { pname = "test-pytestCheckHook-disabledTests-${previousPythonAttrs.pname}"; disabledTests = [ "test_print" ] ++ previousPythonAttrs.disabledTests or [ ]; }); disabledTestPaths = objprint.overridePythonAttrs (previousPythonAttrs: { pname = "test-pytestCheckHook-disabledTestPaths-${previousPythonAttrs.pname}"; disabledTestPaths = [ "tests/test_basic.py" ] ++ previousPythonAttrs.disabledTestPaths or [ ]; }); disabledTestPaths-nonexistent = testers.testBuildFailure ( objprint.overridePythonAttrs (previousPythonAttrs: { pname = "test-pytestCheckHook-disabledTestPaths-nonexistent-${previousPythonAttrs.pname}"; disabledTestPaths = [ "tests/test_foo.py" ] ++ previousPythonAttrs.disabledTestPaths or [ ]; }) ); disabledTestPaths-glob = objprint.overridePythonAttrs (previousPythonAttrs: { pname = "test-pytestCheckHook-disabledTestPaths-glob-${previousPythonAttrs.pname}"; disabledTestPaths = [ "tests/test_obj*.py" ] ++ previousPythonAttrs.disabledTestPaths or [ ]; }); disabledTestPaths-glob-nonexistent = testers.testBuildFailure ( objprint.overridePythonAttrs (previousPythonAttrs: { pname = "test-pytestCheckHook-disabledTestPaths-glob-nonexistent-${previousPythonAttrs.pname}"; disabledTestPaths = [ "tests/test_foo*.py" ] ++ previousPythonAttrs.disabledTestPaths or [ ]; }) ); }; }; } ./pytest-check-hook.sh ) { }; Loading
pkgs/development/interpreters/python/hooks/pytest-check-hook.sh +1 −2 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ function pytestCheckPhase() { concatTo _pathsArray disabledTestPaths for path in "${_pathsArray[@]}"; do # Check if every path glob matches at least one path @pythonCheckInterpreter@ <(cat <<EOF @pythonCheckInterpreter@ - "$path" <<EOF import glob import sys path_glob=sys.argv[1] Loading @@ -27,7 +27,6 @@ if not len(path_glob): if next(glob.iglob(path_glob), None) is None: sys.exit('Disabled tests path glob "{}" does not match any paths. Aborting'.format(path_glob)) EOF ) "$path" flagsArray+=("--ignore-glob=$path") done Loading