From 4c3b99758b4883c7d1057664f0ebf016517434eb Mon Sep 17 00:00:00 2001 From: Teodor Paius Date: Tue, 4 Apr 2023 14:16:46 +0200 Subject: [PATCH] Remove ignoring SkipTest during colection. Now it will raise an error and failure during colection instead of skipping. --- src/_pytest/runner.py | 4 ---- testing/test_nose.py | 2 +- testing/test_unittest.py | 6 +++--- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/_pytest/runner.py b/src/_pytest/runner.py index f861c05a4..7e03ff769 100644 --- a/src/_pytest/runner.py +++ b/src/_pytest/runner.py @@ -375,10 +375,6 @@ def pytest_make_collect_report(collector: Collector) -> CollectReport: outcome: Literal["passed", "skipped", "failed"] = "passed" else: skip_exceptions = [Skipped] - unittest = sys.modules.get("unittest") - if unittest is not None: - # Type ignored because unittest is loaded dynamically. - skip_exceptions.append(unittest.SkipTest) # type: ignore if isinstance(call.excinfo.value, tuple(skip_exceptions)): outcome = "skipped" r_ = collector._repr_failure_py(call.excinfo, "line") diff --git a/testing/test_nose.py b/testing/test_nose.py index e838e79dd..87fa16e4d 100644 --- a/testing/test_nose.py +++ b/testing/test_nose.py @@ -345,7 +345,7 @@ def test_SkipTest_during_collection(pytester: Pytester) -> None: """ ) result = pytester.runpytest(p) - result.assert_outcomes(skipped=1, warnings=0) + result.assert_outcomes(errors=1, skipped=0, warnings=0) def test_SkipTest_in_test(pytester: Pytester) -> None: diff --git a/testing/test_unittest.py b/testing/test_unittest.py index d917d331a..ba75ff33a 100644 --- a/testing/test_unittest.py +++ b/testing/test_unittest.py @@ -1562,6 +1562,6 @@ def test_raising_unittest_skiptest_during_collection( passed, skipped, failed = reprec.countoutcomes() assert passed == 0 # Unittest reports one fake test for a skipped module. - assert skipped == 1 - assert failed == 0 - assert reprec.ret == ExitCode.NO_TESTS_COLLECTED + assert skipped == 0 + assert failed == 1 + assert reprec.ret == ExitCode.INTERRUPTED