From 7510b872e7a2c06e935b0469813320a65f679f64 Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Sat, 31 Dec 2016 08:10:37 -0500 Subject: [PATCH] Refs #25190 -- Removed callable_obj parameter to assertRaisesMessages(). Per deprecation timeline. --- django/test/testcases.py | 12 ++---------- docs/releases/2.0.txt | 3 +++ docs/topics/testing/tools.txt | 5 ----- tests/test_utils/tests.py | 22 +--------------------- 4 files changed, 6 insertions(+), 36 deletions(-) diff --git a/django/test/testcases.py b/django/test/testcases.py index 253b2496798..e342ac282d1 100644 --- a/django/test/testcases.py +++ b/django/test/testcases.py @@ -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:] diff --git a/docs/releases/2.0.txt b/docs/releases/2.0.txt index eed80087a53..d1edbf61800 100644 --- a/docs/releases/2.0.txt +++ b/docs/releases/2.0.txt @@ -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. diff --git a/docs/topics/testing/tools.txt b/docs/topics/testing/tools.txt index 7c40955a0cf..5bb34be1a33 100644 --- a/docs/topics/testing/tools.txt +++ b/docs/topics/testing/tools.txt @@ -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. diff --git a/tests/test_utils/tests.py b/tests/test_utils/tests.py index 54b83f524b0..2a199ec5bce 100644 --- a/tests/test_utils/tests.py +++ b/tests/test_utils/tests.py @@ -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):