diff options
| author | Tim Graham <timograham@gmail.com> | 2015-07-29 11:12:07 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-07-30 10:12:41 -0400 |
| commit | d27e0f04a68cf62088b5b1b3a2c0d6f7e8f89c5d (patch) | |
| tree | 810ad24f4f223ca953c4c61d2d6ad1c512b92d40 /tests/test_utils/tests.py | |
| parent | 635ffc3c37d58eb96ae17d5389dd50bf635413c6 (diff) | |
Fixed #25190 -- Deprecated callable_obj parameter to assertRaisesMessage().
Thanks Aymeric Augustin for review.
Diffstat (limited to 'tests/test_utils/tests.py')
| -rw-r--r-- | tests/test_utils/tests.py | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/tests/test_utils/tests.py b/tests/test_utils/tests.py index 7056ea33de..682e0e08e6 100644 --- a/tests/test_utils/tests.py +++ b/tests/test_utils/tests.py @@ -2,6 +2,7 @@ from __future__ import unicode_literals import unittest +import warnings from django.conf.urls import url from django.contrib.staticfiles.finders import get_finder, get_finders @@ -13,12 +14,14 @@ from django.forms import EmailField, IntegerField from django.http import HttpResponse from django.template.loader import render_to_string from django.test import ( - SimpleTestCase, TestCase, skipIfDBFeature, skipUnlessDBFeature, + SimpleTestCase, TestCase, ignore_warnings, skipIfDBFeature, + skipUnlessDBFeature, ) from django.test.html import HTMLParseError, parse_html from django.test.utils import CaptureQueriesContext, override_settings from django.utils import six from django.utils._os import abspathu +from django.utils.deprecation import RemovedInDjango20Warning from .models import Car, Person, PossessedCar from .views import empty_response @@ -752,11 +755,22 @@ class AssertRaisesMsgTest(SimpleTestCase): raise ValueError("[.*x+]y?") self.assertRaisesMessage(ValueError, "[.*x+]y?", func1) + @ignore_warnings(category=RemovedInDjango20Warning) 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) + + with warnings.catch_warnings(record=True) as warns: + warnings.simplefilter('always') + self.assertRaisesMessage(ValueError, "[.*x+]y?", callable_obj=func1) + + self.assertEqual(len(warns), 1) + self.assertEqual( + str(warns[0].message), + 'The callable_obj kwarg is deprecated. Pass the callable ' + 'as a positional argument instead.' + ) class AssertFieldOutputTests(SimpleTestCase): |
