Skip to content

fix: use node= instead of deprecated nodeid= in unittest skip fixture#14505

Merged
RonnyPfannschmidt merged 1 commit into
pytest-dev:mainfrom
Pierre-Sassoulas:fix-unittest-skip-fixture-nodeid
May 23, 2026
Merged

fix: use node= instead of deprecated nodeid= in unittest skip fixture#14505
RonnyPfannschmidt merged 1 commit into
pytest-dev:mainfrom
Pierre-Sassoulas:fix-unittest-skip-fixture-nodeid

Conversation

@Pierre-Sassoulas
Copy link
Copy Markdown
Member

Summary

main is red on every platform since #14210 landed. The PR was written in February against the old _register_fixture(nodeid=...) API, but commit 121d7a4 deprecated that path yesterday in favor of node=. The PR was approved before that refactor and never re-rebased, so the regression landed unseen — its own CI run was cancelled by the doc-PR merges that immediately followed.

Root cause

_register_unittest_skip_fixture registers an autouse fixture with nodeid=self.nodeid, which now hits the legacy string-baseid path. That path scopes the fixture by string prefix and mis-attributes it relative to subclasses of a @unittest.skip-decorated class — so the skip fixture never preempts the inherited setUp / setUpClass, and tests that should report 1 skipped instead error out.

Three existing tests are broken on every Python/OS:

  • test_setup_inheritance_skipping[test_setup_skip.py-1 skipped]
  • test_setup_inheritance_skipping[test_setup_skip_class.py-1 skipped]
  • test_pdb_teardown_skipped_for_classes[@unittest.skip]

The two existing _register_unittest_setUp* fixtures in the same file already use node=self. This PR aligns the new fixture with that convention.

Test plan

  • pytest testing/test_unittest.py — 71 passed, 9 skipped locally
  • The three previously failing tests now pass
  • No changelog entry — fixes an unreleased regression from Fix autouse fixtures running in @unittest.skip classes #14210 (per CONTRIBUTING: "may skip … if the change doesn't affect the documented behaviour of pytest")

🤖 Generated with Claude Code

PR pytest-dev#14210 registered the new skip fixture with `nodeid=self.nodeid`, the
legacy string-baseid path that 121d7a4 deprecated in favor of `node=`.
The legacy matching mis-scopes the autouse skip fixture so subclasses of
a `@unittest.skip` class still execute their inherited `setUp` /
`setUpClass`, breaking `test_setup_inheritance_skipping` and
`test_pdb_teardown_skipped_for_classes[@unittest.skip]` on main.

Align with the two existing `_register_unittest_setUp*` fixtures in the
same file.
@Pierre-Sassoulas Pierre-Sassoulas added the skip news used on prs to opt out of the changelog requirement label May 23, 2026
@Pierre-Sassoulas
Copy link
Copy Markdown
Member Author

@nicoddemus fyi, I broke main when merging #14210

@RonnyPfannschmidt RonnyPfannschmidt merged commit 58d454a into pytest-dev:main May 23, 2026
33 checks passed
@Pierre-Sassoulas Pierre-Sassoulas deleted the fix-unittest-skip-fixture-nodeid branch May 23, 2026 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip news used on prs to opt out of the changelog requirement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants