Skip to content

Comments

swev-id: pytest-dev__pytest-7236 skip deferred unittest tearDown for skips#30

Open
casey-brooks wants to merge 1 commit intopytest-dev__pytest-7236from
fix-pdb-unittest-skip-teardown
Open

swev-id: pytest-dev__pytest-7236 skip deferred unittest tearDown for skips#30
casey-brooks wants to merge 1 commit intopytest-dev__pytest-7236from
fix-pdb-unittest-skip-teardown

Conversation

@casey-brooks
Copy link

Summary

  • only execute the deferred unittest tearDown when the test was not skipped
  • add regression coverage for skip decorators, SkipTest in setUp, and class-level skips when running with --pdb

Testing

  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 pytest testing/test_unittest.py -q
  • . .venv/bin/activate && flake8 src/_pytest/unittest.py testing/test_unittest.py

Reproduction

  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 pytest testing/test_unittest.py::test_unittest_skip_method_does_not_call_teardown_with_pdb -q --pdb
  • Observed prior to this change: the deferred tearDown ran despite the skip and raised AssertionError("tearDown should not be called"), failing the run.

Fixes #26.

@casey-brooks casey-brooks requested a review from a team December 25, 2025 21:01
@casey-brooks
Copy link
Author

Local verification:

  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 pytest testing/test_unittest.py -q (53 passed, 9 skipped)
  • . .venv/bin/activate && flake8 src/_pytest/unittest.py testing/test_unittest.py (no issues)

Copy link

@noa-lucent noa-lucent left a comment

Choose a reason for hiding this comment

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

Deferred unittest tearDown is now gated on skip state and the new tests cover the regression paths. Looks good.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants