diff options
Diffstat (limited to 'dev-python')
| -rw-r--r-- | dev-python/pytest/files/pytest-9.0.0-skiptest.patch | 79 | ||||
| -rw-r--r-- | dev-python/pytest/pytest-9.0.0-r1.ebuild (renamed from dev-python/pytest/pytest-9.0.0.ebuild) | 5 |
2 files changed, 84 insertions, 0 deletions
diff --git a/dev-python/pytest/files/pytest-9.0.0-skiptest.patch b/dev-python/pytest/files/pytest-9.0.0-skiptest.patch new file mode 100644 index 000000000000..2b266d8042fa --- /dev/null +++ b/dev-python/pytest/files/pytest-9.0.0-skiptest.patch @@ -0,0 +1,79 @@ +From 2ef26ee296c917d1699e283863921c134866d622 Mon Sep 17 00:00:00 2001 +From: Bruno Oliveira <bruno@pytest.org> +Date: Mon, 10 Nov 2025 08:51:35 -0300 +Subject: [PATCH] Restore skipping tests via `raise unittest.SkipTest` + +Revert "Remove unused code related to `nose` (#13528)" + +This reverts commit a620d24376eb2c4bc964f2b6efcc694a4adbbe21 and modifies it adding tests and docs. + +Fixes #13895 +--- a/src/_pytest/unittest.py ++++ b/src/_pytest/unittest.py +@@ -476,6 +476,14 @@ def pytest_runtest_makereport(item: Item, call: CallInfo[None]) -> None: + except AttributeError: + pass + ++ # Convert unittest.SkipTest to pytest.skip. ++ # This covers explicit `raise unittest.SkipTest`. ++ unittest = sys.modules.get("unittest") ++ if unittest and call.excinfo and isinstance(call.excinfo.value, unittest.SkipTest): ++ excinfo = call.excinfo ++ call2 = CallInfo[None].from_call(lambda: skip(str(excinfo.value)), call.when) ++ call.excinfo = call2.excinfo ++ + + def _is_skipped(obj) -> bool: + """Return True if the given object has been marked with @unittest.skip.""" +--- a/testing/test_unittest.py ++++ b/testing/test_unittest.py +@@ -1094,6 +1094,49 @@ def test_two(self): + result.assert_outcomes(passed=2) + + ++def test_skip_setup_class(pytester: Pytester) -> None: ++ """Skipping tests in a class by raising unittest.SkipTest in `setUpClass` (#13985).""" ++ pytester.makepyfile( ++ """ ++ import unittest ++ ++ class Test(unittest.TestCase): ++ ++ @classmethod ++ def setUpClass(cls): ++ raise unittest.SkipTest('Skipping setupclass') ++ ++ def test_foo(self): ++ assert False ++ ++ def test_bar(self): ++ assert False ++ """ ++ ) ++ result = pytester.runpytest() ++ result.assert_outcomes(skipped=2) ++ ++ ++def test_unittest_skip_function(pytester: Pytester) -> None: ++ """ ++ Ensure raising an explicit unittest.SkipTest skips standard pytest functions. ++ ++ Support for this is debatable -- technically we only support unittest.SkipTest in TestCase subclasses, ++ but stating this support here in this test because users currently expect this to work, ++ so if we ever break it we at least know we are breaking this use case (#13985). ++ """ ++ pytester.makepyfile( ++ """ ++ import unittest ++ ++ def test_foo(): ++ raise unittest.SkipTest('Skipping test_foo') ++ """ ++ ) ++ result = pytester.runpytest() ++ result.assert_outcomes(skipped=1) ++ ++ + def test_testcase_handles_init_exceptions(pytester: Pytester) -> None: + """ + Regression test to make sure exceptions in the __init__ method are bubbled up correctly. diff --git a/dev-python/pytest/pytest-9.0.0.ebuild b/dev-python/pytest/pytest-9.0.0-r1.ebuild index fe469fcd07cf..43329010b781 100644 --- a/dev-python/pytest/pytest-9.0.0.ebuild +++ b/dev-python/pytest/pytest-9.0.0-r1.ebuild @@ -45,6 +45,11 @@ BDEPEND=" ) " +PATCHES=( + # https://github.com/pytest-dev/pytest/pull/13912 + "${FILESDIR}/${P}-skiptest.patch" +) + src_test() { # workaround new readline defaults echo "set enable-bracketed-paste off" > "${T}"/inputrc || die |
