diff --git a/src/_pytest/runner.py b/src/_pytest/runner.py index 18d3591abfe..a2d8db51e57 100644 --- a/src/_pytest/runner.py +++ b/src/_pytest/runner.py @@ -409,8 +409,6 @@ def collect() -> list[Item | Collector]: else: skip_exceptions = [Skipped] unittest = sys.modules.get("unittest") - if unittest is not None: - skip_exceptions.append(unittest.SkipTest) if isinstance(call.excinfo.value, tuple(skip_exceptions)): outcome = "skipped" r_ = collector._repr_failure_py(call.excinfo, "line") diff --git a/testing/test_unittest.py b/testing/test_unittest.py index 395c9fe647e..7cefbbe02b4 100644 --- a/testing/test_unittest.py +++ b/testing/test_unittest.py @@ -1718,3 +1718,25 @@ def abstract2(self): pass result = pytester.runpytest() assert result.ret == ExitCode.OK result.assert_outcomes(passed=1) + + +def test_unittest_skip_alias_misuse_fails(pytester): + pytester.makepyfile( + """ + import unittest + + broken = unittest.skip("broken") + + class MyTests(unittest.TestCase): + @broken + def test_good(self): + assert True + + @broken("bar") + def test_bad(self): + assert False + """ + ) + + result = pytester.runpytest() + result.assert_outcomes(errors=1, skipped=0)