diff --git a/django/template/context.py b/django/template/context.py index 166f60fe75..c5a4949e95 100644 --- a/django/template/context.py +++ b/django/template/context.py @@ -1,9 +1,6 @@ -import warnings from contextlib import contextmanager from copy import copy -from django.utils.deprecation import RemovedInDjango20Warning - # Hard-coded processor for easier use of CSRF protection. _builtin_context_processors = ('django.template.context_processors.csrf',) @@ -90,13 +87,6 @@ class BaseContext(object): "Delete a variable from the current context" del self.dicts[-1][key] - def has_key(self, key): - warnings.warn( - "%s.has_key() is deprecated in favor of the 'in' operator." % self.__class__.__name__, - RemovedInDjango20Warning - ) - return key in self - def __contains__(self, key): for d in self.dicts: if key in d: diff --git a/docs/releases/2.0.txt b/docs/releases/2.0.txt index 9be5fda3ca..c679f6ea85 100644 --- a/docs/releases/2.0.txt +++ b/docs/releases/2.0.txt @@ -345,3 +345,5 @@ these features. * ``CommaSeparatedIntegerField`` is removed, except for support in historical migrations. + +* The template ``Context.has_key()`` method is removed. diff --git a/tests/template_tests/test_context.py b/tests/template_tests/test_context.py index 79f7b06794..41e469eaab 100644 --- a/tests/template_tests/test_context.py +++ b/tests/template_tests/test_context.py @@ -1,13 +1,10 @@ # -*- coding: utf-8 -*- -import warnings - from django.http import HttpRequest from django.template import ( Context, Engine, RequestContext, Template, Variable, VariableDoesNotExist, ) from django.template.context import RenderContext -from django.test import RequestFactory, SimpleTestCase, ignore_warnings -from django.utils.deprecation import RemovedInDjango20Warning +from django.test import RequestFactory, SimpleTestCase class ContextTests(SimpleTestCase): @@ -184,26 +181,6 @@ class ContextTests(SimpleTestCase): """ RequestContext(HttpRequest()).new().new() - @ignore_warnings(category=RemovedInDjango20Warning) - def test_has_key(self): - a = Context({'a': 1}) - b = RequestContext(HttpRequest(), {'a': 1}) - msg = "Context.has_key() is deprecated in favor of the 'in' operator." - msg2 = "RequestContext.has_key() is deprecated in favor of the 'in' operator." - - with warnings.catch_warnings(record=True) as warns: - warnings.simplefilter('always') - self.assertIs(a.has_key('a'), True) - self.assertIs(a.has_key('b'), False) - self.assertIs(b.has_key('a'), True) - self.assertIs(b.has_key('b'), False) - - self.assertEqual(len(warns), 4) - self.assertEqual(str(warns[0].message), msg) - self.assertEqual(str(warns[1].message), msg) - self.assertEqual(str(warns[2].message), msg2) - self.assertEqual(str(warns[3].message), msg2) - def test_set_upward(self): c = Context({'a': 1}) c.set_upward('a', 2)