diff options
author | Nikita Sobolev <mail@sobolevn.me> | 2024-06-15 13:33:14 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-15 10:33:14 +0000 |
commit | 42ebdd83bb194f054fe5a10b3caa0c3a95be3679 (patch) | |
tree | 1866edda1014c3efe5021b591605a8bedd449e25 /Lib/test/test_unittest/test_case.py | |
parent | d4039d3f6f8cb7738c5cd272dde04171446dfd2b (diff) | |
download | cpython-42ebdd83bb194f054fe5a10b3caa0c3a95be3679.tar.gz cpython-42ebdd83bb194f054fe5a10b3caa0c3a95be3679.zip |
gh-120544: Add `else: fail()` to tests where exception is expected (#120545)
Diffstat (limited to 'Lib/test/test_unittest/test_case.py')
-rw-r--r-- | Lib/test/test_unittest/test_case.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_unittest/test_case.py b/Lib/test/test_unittest/test_case.py index 17420909402..b4b2194a09c 100644 --- a/Lib/test/test_unittest/test_case.py +++ b/Lib/test/test_unittest/test_case.py @@ -1151,6 +1151,8 @@ test case # need to remove the first line of the error message error = str(e).split('\n', 1)[1] self.assertEqual(sample_text_error, error) + else: + self.fail(f'{self.failureException} not raised') def testAssertEqualSingleLine(self): sample_text = "laden swallows fly slowly" @@ -1167,6 +1169,8 @@ test case # need to remove the first line of the error message error = str(e).split('\n', 1)[1] self.assertEqual(sample_text_error, error) + else: + self.fail(f'{self.failureException} not raised') def testAssertEqualwithEmptyString(self): '''Verify when there is an empty string involved, the diff output @@ -1184,6 +1188,8 @@ test case # need to remove the first line of the error message error = str(e).split('\n', 1)[1] self.assertEqual(sample_text_error, error) + else: + self.fail(f'{self.failureException} not raised') def testAssertEqualMultipleLinesMissingNewlineTerminator(self): '''Verifying format of diff output from assertEqual involving strings @@ -1204,6 +1210,8 @@ test case # need to remove the first line of the error message error = str(e).split('\n', 1)[1] self.assertEqual(sample_text_error, error) + else: + self.fail(f'{self.failureException} not raised') def testAssertEqualMultipleLinesMismatchedNewlinesTerminators(self): '''Verifying format of diff output from assertEqual involving strings @@ -1227,6 +1235,8 @@ test case # need to remove the first line of the error message error = str(e).split('\n', 1)[1] self.assertEqual(sample_text_error, error) + else: + self.fail(f'{self.failureException} not raised') def testEqualityBytesWarning(self): if sys.flags.bytes_warning: |