diff options
| author | Tim Graham <timograham@gmail.com> | 2015-07-30 15:00:24 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-07-31 09:19:27 -0400 |
| commit | 1c7c782d6e7cdce09a982f05d468d538698c3004 (patch) | |
| tree | 99cce47cc25d61d109108d425f2edf122a508891 /tests/test_utils/tests.py | |
| parent | faa2a0f662ed6fe0b90d10e98cc8ee3795d9307c (diff) | |
Fixed #25188 -- Improved message raised by SimpleTestCase.assertRaisesMessage().
Thanks Chris Jerdonek for the suggestion and help with the patch.
Diffstat (limited to 'tests/test_utils/tests.py')
| -rw-r--r-- | tests/test_utils/tests.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/test_utils/tests.py b/tests/test_utils/tests.py index 682e0e08e6..a02bfb6397 100644 --- a/tests/test_utils/tests.py +++ b/tests/test_utils/tests.py @@ -749,6 +749,20 @@ class SkippingExtraTests(TestCase): class AssertRaisesMsgTest(SimpleTestCase): + def test_assert_raises_message(self): + msg = "'Expected message' not found in 'Unexpected message'" + # context manager form of assertRaisesMessage() + with self.assertRaisesMessage(AssertionError, msg): + with self.assertRaisesMessage(ValueError, "Expected message"): + raise ValueError("Unexpected message") + + # callable form + def func(): + raise ValueError("Unexpected message") + + with self.assertRaisesMessage(AssertionError, msg): + self.assertRaisesMessage(ValueError, "Expected message", func) + def test_special_re_chars(self): """assertRaisesMessage shouldn't interpret RE special chars.""" def func1(): |
