mirror of
https://github.com/django/django.git
synced 2025-02-03 22:17:24 +00:00
Added backwards compatibility for assertRaisesMessage callable_obj param.
This was broken in c2bc1cefdcbbf074408f4a4cace88b315cf9d652 (refs #23763).
This commit is contained in:
parent
a0175724b0
commit
e89c3a4603
@ -589,6 +589,10 @@ class SimpleTestCase(unittest.TestCase):
|
|||||||
args: Function to be called and extra positional args.
|
args: Function to be called and extra positional args.
|
||||||
kwargs: Extra kwargs.
|
kwargs: Extra kwargs.
|
||||||
"""
|
"""
|
||||||
|
# callable_obj was a documented kwarg in Django 1.8 and older.
|
||||||
|
callable_obj = kwargs.pop('callable_obj', None)
|
||||||
|
if callable_obj:
|
||||||
|
args = (callable_obj,) + args
|
||||||
return six.assertRaisesRegex(self, expected_exception,
|
return six.assertRaisesRegex(self, expected_exception,
|
||||||
re.escape(expected_message), *args, **kwargs)
|
re.escape(expected_message), *args, **kwargs)
|
||||||
|
|
||||||
|
@ -752,6 +752,12 @@ class AssertRaisesMsgTest(SimpleTestCase):
|
|||||||
raise ValueError("[.*x+]y?")
|
raise ValueError("[.*x+]y?")
|
||||||
self.assertRaisesMessage(ValueError, "[.*x+]y?", func1)
|
self.assertRaisesMessage(ValueError, "[.*x+]y?", func1)
|
||||||
|
|
||||||
|
def test_callable_obj_param(self):
|
||||||
|
# callable_obj was a documented kwarg in Django 1.8 and older.
|
||||||
|
def func1():
|
||||||
|
raise ValueError("[.*x+]y?")
|
||||||
|
self.assertRaisesMessage(ValueError, "[.*x+]y?", callable_obj=func1)
|
||||||
|
|
||||||
|
|
||||||
class AssertFieldOutputTests(SimpleTestCase):
|
class AssertFieldOutputTests(SimpleTestCase):
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user