You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
pytest 9.0 errors instead of skipping when unittest.SkipTest is raised #13895
I actually use subclasses of unittest.SkipTest and I don't think I ever try to catch them in an except block so I should be able to convert them to functions wrapping pytest.skip(). But I imagine someone else might not.
Also, I have people not familiar with pytest on this codebase, and raise MySkipTestSubclass() probably makes the control flow clearer for them than calling my_pytestdotskip_wrapper()
Yeah, chiming in from a project where pytest is entirely optional, everything is defined with pure unittest and people can run pytest over it if they want. The skips result in errors now when using pytest, but not when using the python included unittest runner.
Reacted by Liam DeVoe, Peter Hawkins, David Cain and Ray Luo
Being able to raise unittest.SkipTest() without worrying about whether my users are running pytest or unittest is nice for other testing libraries like Hypothesis too, so I'd support restoring the old behavior 🙂
Reacted by xqt, Chris Withers, David Cain and Ray Luo
Yeah, I hit this here, which is using Sybil's skip parser (code).
There's a weird thing in that error, whereby it looks like importing twisted ends up with unittest's SkipTest being replaced by twisted.trial.unittest.SkipTest just by way of importing twisted at some point, but I reproduced the problem folks are reporting above even with it uninstalled.
I guess my feedback from a library maintainer is to please generously support SkipTest exceptions if at all possible 😓
Is there an ETA for this fix to be released as 9.0.1? Some of our test automation pipelines have been failing since the release of pytest 9.0.0 3 days ago.
In fact we were about to release 9.0.1 today but ran into some problems: #13928. Thanks to @webknjaz the solution was found, I will trigger a new build shortly.
Reacted by 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко)
Activity
bluetech commentedon Nov 8, 2025
Thanks for the report.
Bisected to a620d24 (@nicoddemus).
However, you raising a unittest exception in a non-unittest test, is there a reason for that? Can you use
pytest.skip()instead?bluetech commentedon Nov 8, 2025
Just to clarify my comment, raising
unittest.SkipTeststill works inside a unittestTestCase.progval commentedon Nov 8, 2025
It's inherited from before I used pytest.
I actually use subclasses of
unittest.SkipTestand I don't think I ever try to catch them in anexceptblock so I should be able to convert them to functions wrappingpytest.skip(). But I imagine someone else might not.progval commentedon Nov 8, 2025
Also, I have people not familiar with pytest on this codebase, and
raise MySkipTestSubclass()probably makes the control flow clearer for them than callingmy_pytestdotskip_wrapper()nicoddemus commentedon Nov 8, 2025
Looking at the commit, this worked before due to nose support, which has since then been removed.
I don't think we should continue to support this usage, TBH. Seems simple enough for users to adapt this code to use
pytest.skip()instead.What do you folks think?
mkmoisen commentedon Nov 8, 2025
@bluetech
That is not the case for me now in 9.0.0.
Raising
unittest.SkipTestinside ofunittest.TestCaseis resulting in pytests reporting an error instead of a skip.mkmoisen commentedon Nov 8, 2025
@nicoddemus
Please see my comment above.
unittest.SkipTestis broken for me now when using it in aunittest.TestCase.Thank you.
nicoddemus commentedon Nov 8, 2025
Oh if that's the case then definitely this is a problem. I will look into it, thanks!
Berserker66 commentedon Nov 8, 2025
Yeah, chiming in from a project where pytest is entirely optional, everything is defined with pure unittest and people can run pytest over it if they want. The skips result in errors now when using pytest, but not when using the python included unittest runner.
Zac-HD commentedon Nov 9, 2025
Being able to
raise unittest.SkipTest()without worrying about whether my users are running pytest or unittest is nice for other testing libraries like Hypothesis too, so I'd support restoring the old behavior 🙂tests: avoid Pytest 9.0.0
cjw296 commentedon Nov 9, 2025
Yeah, I hit this here, which is using Sybil's skip parser (code).
There's a weird thing in that error, whereby it looks like importing twisted ends up with unittest's
SkipTestbeing replaced bytwisted.trial.unittest.SkipTestjust by way of importingtwistedat some point, but I reproduced the problem folks are reporting above even with it uninstalled.I guess my feedback from a library maintainer is to please generously support
SkipTestexceptions if at all possible 😓15 remaining items
Restore skipping tests via `raise unittest.SkipTest` (pytest-dev#13912)
Restore skipping tests via `raise unittest.SkipTest` (#13912) (#13916)
dev-python/pytest: Backport fix for SkipTest exception handling
rayluo commentedon Nov 11, 2025
Is there an ETA for this fix to be released as 9.0.1? Some of our test automation pipelines have been failing since the release of pytest 9.0.0 3 days ago.
nicoddemus commentedon Nov 11, 2025
Soon. 👍
In fact we were about to release 9.0.1 today but ran into some problems: #13928. Thanks to @webknjaz the solution was found, I will trigger a new build shortly.
Exclude pytest 9.0.0 from pip installation
pytest-dev/pytest#13895 now fixed in pytest 9.0.1
Exclude pytest 9.0.0 from pip installation
CI: Fix issues caused by pytest v9 (huggingface#2904)
chore(deps): update pytest (major)
Merge branch 'renovate/pytest-9.x' into 'main'
CI: Fix issues caused by pytest v9 (huggingface#2904)
🔒️ Update dependency pytest to v9 [SECURITY] (#16)
[SECURITY] Update dependency pytest to v9 [SECURITY] (#2)
Update dependency pytest to v9 (#35)