-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
gh-106300: Improve assertRaises(Exception)
usage in test_runner
#106737
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On one hand, most of these changes are not necessary, because exceptions are differentiated by their messages.
On other hand, a bug similar to the bug in doClassCleanups()
testing may occur again, and a custom exception will help catch it.
LGTM. Thank you.
Thanks @sobolevn for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12. |
GH-108006 is a backport of this pull request to the 3.12 branch. |
…ythonGH-106737) Use a custom exception to prevent unintentional silence of actual errors. (cherry picked from commit fd9d70a) Co-authored-by: Nikita Sobolev <[email protected]>
GH-108007 is a backport of this pull request to the 3.11 branch. |
…ythonGH-106737) Use a custom exception to prevent unintentional silence of actual errors. (cherry picked from commit fd9d70a) Co-authored-by: Nikita Sobolev <[email protected]>
…GH-106737) (GH-108007) Use a custom exception to prevent unintentional silence of actual errors. (cherry picked from commit fd9d70a) Co-authored-by: Nikita Sobolev <[email protected]>
…GH-106737) (#108006) gh-106300: Improve errors testing in test_unittest.test_runner (GH-106737) Use a custom exception to prevent unintentional silence of actual errors. (cherry picked from commit fd9d70a) Co-authored-by: Nikita Sobolev <[email protected]>
Explaining changes:
raise Exception
to raise our newCustomError
, so we can use it withself.assertRaises(CustomError)
CustomErrorRepr
helper, so it would work for two styles of test execution (direct and viaregtest
):assertRaises(Regex)?(Exception)
is problematic #106300 (comment) NowTestableTest.doClassCleanups()
is not expected to raise any exceptions :)assertRaises(Regex)?(Exception)
is problematic #106300