Refs #25190 -- Removed callable_obj parameter to assertRaisesMessages().

Per deprecation timeline.
This commit is contained in:
Tim Graham 2016-12-31 08:10:37 -05:00
parent 9f9a3d643e
commit 7510b872e7
4 changed files with 6 additions and 36 deletions

View File

@ -6,7 +6,6 @@ import posixpath
import sys
import threading
import unittest
import warnings
from collections import Counter
from contextlib import contextmanager
from copy import copy
@ -36,7 +35,6 @@ from django.test.utils import (
)
from django.utils import six
from django.utils.decorators import classproperty
from django.utils.deprecation import RemovedInDjango20Warning
from django.utils.encoding import force_text
from django.utils.six.moves.urllib.parse import (
unquote, urljoin, urlparse, urlsplit,
@ -606,14 +604,8 @@ 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:
warnings.warn(
'The callable_obj kwarg is deprecated. Pass the callable '
'as a positional argument instead.', RemovedInDjango20Warning
)
elif len(args):
callable_obj = None
if len(args):
callable_obj = args[0]
args = args[1:]

View File

@ -306,3 +306,6 @@ these features.
* The ``current_app`` parameter to the ``contrib.auth`` function-based views is
removed.
* The ``callable_obj`` keyword argument to
``SimpleTestCase.assertRaisesMessage()`` is removed.

View File

@ -1351,11 +1351,6 @@ your test suite.
with self.assertRaisesMessage(ValueError, 'invalid literal for int()'):
int('a')
.. deprecated:: 1.9
Passing ``callable`` as a keyword argument called ``callable_obj`` is
deprecated. Pass the callable as a positional argument instead.
.. method:: SimpleTestCase.assertFieldOutput(fieldclass, valid, invalid, field_args=None, field_kwargs=None, empty_value='')
Asserts that a form field behaves correctly with various inputs.

View File

@ -3,7 +3,6 @@ from __future__ import unicode_literals
import sys
import unittest
import warnings
from django.conf.urls import url
from django.contrib.staticfiles.finders import get_finder, get_finders
@ -14,8 +13,7 @@ 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, ignore_warnings, skipIfDBFeature,
skipUnlessDBFeature,
SimpleTestCase, TestCase, skipIfDBFeature, skipUnlessDBFeature,
)
from django.test.html import HTMLParseError, parse_html
from django.test.utils import (
@ -25,7 +23,6 @@ from django.test.utils import (
from django.urls import NoReverseMatch, reverse
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
@ -831,23 +828,6 @@ class AssertRaisesMsgTest(SimpleTestCase):
with 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?")
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):