Skip to content

Tests: Use pytest.skip instead of unittest.SkipTest, now that's broken in pytest 9.0#9459

Closed
bblommers wants to merge 1 commit intogetmoto:masterfrom
bblommers:tests-use-pytest-skip-instead-of-unittest
Closed

Tests: Use pytest.skip instead of unittest.SkipTest, now that's broken in pytest 9.0#9459
bblommers wants to merge 1 commit intogetmoto:masterfrom
bblommers:tests-use-pytest-skip-instead-of-unittest

Conversation

@bblommers
Copy link
Collaborator

Relevant bug report: pytest-dev/pytest#13895

It looks like it may be reverted, but that's still under discussion, and 200+ of our tests break because of it. So I'll probably just merge anyway.

def test_request_exportable_certificate():
if not settings.TEST_DECORATOR_MODE:
raise SkipTest("Can only change setting in DecoratorMode")
raise pytest.skip("Can only change setting in DecoratorMode")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
raise pytest.skip("Can only change setting in DecoratorMode")
pytest.skip("Can only change setting in DecoratorMode")

This raises its own exception:
https://github.com/pytest-dev/pytest/blob/6eb7609c7d738da904de5c8b0b7c9c2a80ddf3e0/src/_pytest/outcomes.py#L137-L142
but you should use it like a normal function call.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

TIL! Thanks for the hint @chriselion

@chriselion
Copy link
Contributor

It might be simpler to pin to pytest<9.0.0 in requirements-tests.txt for now, at least until the upstream issue is resolved?

@bblommers
Copy link
Collaborator Author

It might be simpler to pin to pytest<9.0.0 in requirements-tests.txt for now, at least until the upstream issue is resolved?

Yeah, I agree. I wasn't quite sure that the pytest maintainers would actually fix it - but it is already fixed now. I've raised #9460 to do just that 👍

@bblommers bblommers closed this Nov 10, 2025
@bblommers bblommers deleted the tests-use-pytest-skip-instead-of-unittest branch November 10, 2025 21:28
@chriselion
Copy link
Contributor

Oh nice, I didn't see they had reverted. Yeah, I'd expect them to publish a patch version and yank 9.0.0 (so you shouldn't need to exclude it) soon.

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