Skip to content

Conversation

@nicoddemus
Copy link
Member

Revert "Remove unused code related to nose (#13528)"

This reverts commit a620d24 and modifies it adding tests and docs.

Fixes #13895

Revert "Remove unused code related to `nose` (pytest-dev#13528)"

This reverts commit a620d24 and modifies it adding tests and docs.

Fixes pytest-dev#13895
@nicoddemus nicoddemus added the backport 9.0.x apply to PRs at any point; backports the changes to the 9.0.x branch label Nov 10, 2025
Comment on lines +483 to +485
excinfo = call.excinfo
call2 = CallInfo[None].from_call(lambda: skip(str(excinfo.value)), call.when)
call.excinfo = call2.excinfo
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code is quite hacky, I do wonder why the code in the runner doesn't do the trick:

skip_exceptions = [Skipped]
unittest = sys.modules.get("unittest")
if unittest is not None:
skip_exceptions.append(unittest.SkipTest)

In any case we can analyze it later, for 9.0 reverting seems best.

@nicoddemus nicoddemus merged commit 6a47389 into pytest-dev:main Nov 10, 2025
33 checks passed
@nicoddemus nicoddemus deleted the ut-skip-13895 branch November 10, 2025 17:50
@patchback
Copy link

patchback bot commented Nov 10, 2025

Backport to 9.0.x: 💚 backport PR created

✅ Backport PR branch: patchback/backports/9.0.x/6a47389c7813ec7ed395c0279c4b7685fde9f95a/pr-13912

Backported as #13916

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

patchback bot pushed a commit that referenced this pull request Nov 10, 2025
Revert "Remove unused code related to `nose` (#13528)"

This reverts commit a620d24 and modifies it adding tests and docs.

Fixes #13895

(cherry picked from commit 6a47389)
nicoddemus added a commit that referenced this pull request Nov 10, 2025
Revert "Remove unused code related to `nose` (#13528)"

This reverts commit a620d24 and modifies it adding tests and docs.

Fixes #13895

(cherry picked from commit 6a47389)

Co-authored-by: Bruno Oliveira <bruno@pytest.org>
@mgorny
Copy link
Contributor

mgorny commented Nov 11, 2025

For the record, this also fixes use of unittest.skipIf() on top-level tests, i.e.:

from unittest import skipIf


@skipIf(True, "skipping")
def test_foo():
    pass

…which is something botocore does for whatever reason.

gentoo-bot pushed a commit to gentoo/gentoo that referenced this pull request Nov 11, 2025
Backport an upstream fix for handling SkipTest exceptions raised
outside unittest.TestCase, which also happens to fix unittest.skipIf()
on top-level test functions (needed for dev-python/botocore).

Bug: pytest-dev/pytest#13895
Pull-Request: pytest-dev/pytest#13912
Signed-off-by: Michał Górny <mgorny@gentoo.org>
@rayluo
Copy link

rayluo commented Nov 11, 2025

Ran into this issue in my code base, too. When will this fix be released as pytest 9.0.1?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport 9.0.x apply to PRs at any point; backports the changes to the 9.0.x branch bot:chronographer:provided (automation) changelog entry is part of PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pytest 9.0 errors instead of skipping when unittest.SkipTest is raised

4 participants