Revert "Deprecate raising unittest.SkipTest to skip tests during collection" (#9710)

This reverts commit 25e657bfc1.

Turns out that this *is* a working unittest feature, which pytest should
support, so undo the deprecation.
This commit is contained in:
Ran Benita
2022-02-23 15:59:54 +02:00
committed by GitHub
parent 0c80a1c836
commit 7b6e477e2f
8 changed files with 33 additions and 43 deletions

View File

@@ -86,23 +86,6 @@ def test_private_is_deprecated() -> None:
PrivateInit(10, _ispytest=True)
def test_raising_unittest_skiptest_during_collection_is_deprecated(
pytester: Pytester,
) -> None:
pytester.makepyfile(
"""
import unittest
raise unittest.SkipTest()
"""
)
result = pytester.runpytest()
result.stdout.fnmatch_lines(
[
"*PytestRemovedIn8Warning: Raising unittest.SkipTest*",
]
)
@pytest.mark.parametrize("hooktype", ["hook", "ihook"])
def test_hookproxy_warnings_for_pathlib(tmp_path, hooktype, request):
path = legacy_path(tmp_path)

View File

@@ -345,7 +345,7 @@ def test_SkipTest_during_collection(pytester: Pytester) -> None:
"""
)
result = pytester.runpytest(p)
result.assert_outcomes(skipped=1, warnings=1)
result.assert_outcomes(skipped=1, warnings=0)
def test_SkipTest_in_test(pytester: Pytester) -> None:

View File

@@ -1498,3 +1498,30 @@ def test_traceback_pruning(pytester: Pytester) -> None:
assert passed == 1
assert failed == 1
assert reprec.ret == 1
def test_raising_unittest_skiptest_during_collection(
pytester: Pytester,
) -> None:
pytester.makepyfile(
"""
import unittest
class TestIt(unittest.TestCase):
def test_it(self): pass
def test_it2(self): pass
raise unittest.SkipTest()
class TestIt2(unittest.TestCase):
def test_it(self): pass
def test_it2(self): pass
"""
)
reprec = pytester.inline_run()
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