Commit 9346e6aa authored by Yueh-Shun Li's avatar Yueh-Shun Li
Browse files

python3Packages.pytestCheckHook: add tests

parent 2e512e7c
Loading
Loading
Loading
Loading
+48 −1
Original line number Diff line number Diff line
@@ -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
  ) { };