-
-
Notifications
You must be signed in to change notification settings - Fork 32.7k
Closed
Labels
testsTests in the Lib/test dirTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Most except self.failureClass
cases have else
branch where we can ensure that the exception really did happen:
cpython/Lib/test/test_unittest/test_case.py
Lines 831 to 837 in d4039d3
try: | |
self.assertSequenceEqual(seq1, seq2) | |
except self.failureException as e: | |
msg = e.args[0] | |
else: | |
self.fail('assertSequenceEqual did not fail.') |
But, some rare ones do not have them:
cpython/Lib/test/test_unittest/test_case.py
Lines 1148 to 1154 in d4039d3
try: | |
self.assertMultiLineEqual(sample_text, revised_sample_text) | |
except self.failureException as e: | |
# need to remove the first line of the error message | |
error = str(e).split('\n', 1)[1] | |
self.assertEqual(sample_text_error, error) | |
So, in theory they can just succeed and except
branch might never be called. This is a theorical problem, but it is still a problem.
I propose to add else
branches to these tests, just to be safe.
Linked PRs
Metadata
Metadata
Assignees
Labels
testsTests in the Lib/test dirTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error