mirror of
https://github.com/django/django.git
synced 2025-08-04 10:59:45 +00:00
Fixed #25188 -- Improved message raised by SimpleTestCase.assertRaisesMessage().
Thanks Chris Jerdonek for the suggestion and help with the patch.
This commit is contained in:
parent
faa2a0f662
commit
1c7c782d6e
2 changed files with 34 additions and 6 deletions
|
@ -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():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue