Bug report
Most except self.failureClass cases have else branch where we can ensure that the exception really did happen:
|
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:
|
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
Bug report
Most
except self.failureClasscases haveelsebranch where we can ensure that the exception really did happen:cpython/Lib/test/test_unittest/test_case.py
Lines 831 to 837 in d4039d3
But, some rare ones do not have them:
cpython/Lib/test/test_unittest/test_case.py
Lines 1148 to 1154 in d4039d3
So, in theory they can just succeed and
exceptbranch might never be called. This is a theorical problem, but it is still a problem.I propose to add
elsebranches to these tests, just to be safe.Linked PRs
else: fail()to tests where exception is expected #120545else: fail()to tests where exception is expected (GH-120545) #120546else: fail()to tests where exception is expected (GH-120545) #120547