gh-106300: Improve assertRaises(Exception) usages in tests#106302
gh-106300: Improve assertRaises(Exception) usages in tests#106302brettcannon merged 2 commits intopython:mainfrom
assertRaises(Exception) usages in tests#106302Conversation
serhiy-storchaka
left a comment
There was a problem hiding this comment.
LGTM. But we need to run tests on buildbots to ensure that the same exceptions are raised on all platforms.
There are also few assertRaises(BaseException). Could you add these cases too?
|
Of course, if these cases are not already excluded by your rules. |
|
For me it would be easier to merge this one first, then I can work on |
|
Changes in mock look fine to me, so removing myself as a reviewer. Thanks for the work! :-) |
|
Thanks @sobolevn for the PR, and @brettcannon for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12. |
|
Thanks! |
|
Sorry, @sobolevn and @brettcannon, I could not cleanly backport this to |
|
GH-106534 is a backport of this pull request to the 3.12 branch. |
|
|
|
…ythonGH-106302) (cherry picked from commit 6e6a4cd)
…ests (pythonGH-106302). (cherry picked from commit 6e6a4cd) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
…ests (pythonGH-106302). (cherry picked from commit 6e6a4cd) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
|
GH-106545 is a backport of this pull request to the 3.11 branch. |
Things I did:
zlib.erroras an exampleCustomErrordefinitions to be sure that we get what we expect in a custom raising codeassertRaisesRegexwhere possibleNote that
test_unittestwill have its own PR due to bugs I found in #106300 (comment)This PR does only change semantics, no bugs.
assertRaises(Regex)?(Exception)is problematic #106300