summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_mailbox.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_mailbox.py')
-rw-r--r--Lib/test/test_mailbox.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/Lib/test/test_mailbox.py b/Lib/test/test_mailbox.py
index 4c592ea..4977a93 100644
--- a/Lib/test/test_mailbox.py
+++ b/Lib/test/test_mailbox.py
@@ -116,10 +116,13 @@ class TestMailbox(TestBase):
self.assertMailboxEmpty()
def test_add_that_raises_leaves_mailbox_empty(self):
+ class CustomError(Exception): ...
+ exc_msg = "a fake error"
+
def raiser(*args, **kw):
- raise Exception("a fake error")
+ raise CustomError(exc_msg)
support.patch(self, email.generator.BytesGenerator, 'flatten', raiser)
- with self.assertRaises(Exception):
+ with self.assertRaisesRegex(CustomError, exc_msg):
self._box.add(email.message_from_string("From: Alphöso"))
self.assertEqual(len(self._box), 0)
self._box.close()