diff options
| author | Tim Graham <timograham@gmail.com> | 2015-05-17 19:09:30 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-05-18 10:04:18 -0400 |
| commit | e89c3a46035e9fe17c373a6c9cd63b9fd631d596 (patch) | |
| tree | 2be88d9fa1823391f7f3db3818a4034ea8f3b50f | |
| parent | a0175724b086127a4e13612042961d3ba88d6bd9 (diff) | |
Added backwards compatibility for assertRaisesMessage callable_obj param.
This was broken in c2bc1cefdcbbf074408f4a4cace88b315cf9d652 (refs #23763).
| -rw-r--r-- | django/test/testcases.py | 4 | ||||
| -rw-r--r-- | tests/test_utils/tests.py | 6 |
2 files changed, 10 insertions, 0 deletions
diff --git a/django/test/testcases.py b/django/test/testcases.py index 86a275e7fd..421134572d 100644 --- a/django/test/testcases.py +++ b/django/test/testcases.py @@ -589,6 +589,10 @@ class SimpleTestCase(unittest.TestCase): args: Function to be called and extra positional args. 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, re.escape(expected_message), *args, **kwargs) diff --git a/tests/test_utils/tests.py b/tests/test_utils/tests.py index 9c6861393a..57c0e6c2e7 100644 --- a/tests/test_utils/tests.py +++ b/tests/test_utils/tests.py @@ -752,6 +752,12 @@ class AssertRaisesMsgTest(SimpleTestCase): raise ValueError("[.*x+]y?") 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): |
