Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Lib/test/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1820,6 +1820,8 @@ def f():
except self.failureException:
with support.captured_stderr() as err:
sys.__excepthook__(*sys.exc_info())
else:
self.fail("assertRaisesRegex should have failed.")

self.assertIn("aab", err.getvalue())

Expand Down
10 changes: 10 additions & 0 deletions Lib/test/test_unittest/test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -1132,6 +1132,8 @@ def testAssertMultiLineEqual(self):
# 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"
Expand All @@ -1148,6 +1150,8 @@ def testAssertEqualSingleLine(self):
# 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
Expand All @@ -1165,6 +1169,8 @@ def testAssertEqualwithEmptyString(self):
# 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
Expand All @@ -1185,6 +1191,8 @@ def testAssertEqualMultipleLinesMissingNewlineTerminator(self):
# 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
Expand All @@ -1208,6 +1216,8 @@ def testAssertEqualMultipleLinesMismatchedNewlinesTerminators(self):
# 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:
Expand Down