summaryrefslogtreecommitdiff
path: root/tests/test_client_regress
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2014-12-21 21:19:05 +0100
committerClaude Paroz <claude@2xlibre.net>2014-12-30 18:16:25 +0100
commit51890ce8898f821d28f2f6fb6071c936e9bd88f0 (patch)
tree6522c597d411086b0a5c2ec3dd7a1d9bc2feeafd /tests/test_client_regress
parent66f9a74b4514bd259976ce8ee3a4e78288358a5f (diff)
downloaddjango-51890ce8898f821d28f2f6fb6071c936e9bd88f0.tar.gz
Applied ignore_warnings to Django tests
Diffstat (limited to 'tests/test_client_regress')
-rw-r--r--tests/test_client_regress/tests.py40
-rw-r--r--tests/test_client_regress/views.py8
2 files changed, 23 insertions, 25 deletions
diff --git a/tests/test_client_regress/tests.py b/tests/test_client_regress/tests.py
index fc68c5b5f7..6f8d97c886 100644
--- a/tests/test_client_regress/tests.py
+++ b/tests/test_client_regress/tests.py
@@ -6,16 +6,15 @@ from __future__ import unicode_literals
import os
import itertools
-import warnings
from django.core.urlresolvers import reverse, NoReverseMatch
from django.template import TemplateSyntaxError, Context, Template
-from django.test import Client, TestCase, override_settings
+from django.test import Client, TestCase, ignore_warnings, override_settings
from django.test.client import RedirectCycleError, RequestFactory, encode_file
from django.test.utils import ContextList, str_prefix
from django.template.response import SimpleTemplateResponse
+from django.utils.deprecation import RemovedInDjango19Warning, RemovedInDjango20Warning
from django.utils._os import upath
-from django.utils.deprecation import RemovedInDjango20Warning
from django.utils.translation import ugettext_lazy
from django.http import HttpResponse
from django.contrib.auth.signals import user_logged_out, user_logged_in
@@ -952,6 +951,7 @@ class zzUrlconfSubstitutionTests(TestCase):
class ContextTests(TestCase):
fixtures = ['testdata']
+ @ignore_warnings(category=RemovedInDjango19Warning) # `request.REQUEST` is deprecated
def test_single_context(self):
"Context variables can be retrieved from a single context"
response = self.client.get("/request_data/", data={'foo': 'whiz'})
@@ -967,6 +967,7 @@ class ContextTests(TestCase):
except KeyError as e:
self.assertEqual(e.args[0], 'does-not-exist')
+ @ignore_warnings(category=RemovedInDjango19Warning) # `request.REQUEST` is deprecated
def test_inherited_context(self):
"Context variables can be retrieved from a list of contexts"
response = self.client.get("/request_data_extended/", data={'foo': 'whiz'})
@@ -998,23 +999,22 @@ class ContextTests(TestCase):
'python', 'dolly'},
l.keys())
+ @ignore_warnings(category=RemovedInDjango20Warning)
def test_15368(self):
- with warnings.catch_warnings():
- warnings.filterwarnings("ignore", category=RemovedInDjango20Warning)
- # Need to insert a context processor that assumes certain things about
- # the request instance. This triggers a bug caused by some ways of
- # copying RequestContext.
- with self.settings(TEMPLATES=[{
- 'BACKEND': 'django.template.backends.django.DjangoTemplates',
- 'APP_DIRS': True,
- 'OPTIONS': {
- 'context_processors': [
- 'test_client_regress.context_processors.special',
- ],
- },
- }]):
- response = self.client.get("/request_context_view/")
- self.assertContains(response, 'Path: /request_context_view/')
+ # Need to insert a context processor that assumes certain things about
+ # the request instance. This triggers a bug caused by some ways of
+ # copying RequestContext.
+ with self.settings(TEMPLATES=[{
+ 'BACKEND': 'django.template.backends.django.DjangoTemplates',
+ 'APP_DIRS': True,
+ 'OPTIONS': {
+ 'context_processors': [
+ 'test_client_regress.context_processors.special',
+ ],
+ },
+ }]):
+ response = self.client.get("/request_context_view/")
+ self.assertContains(response, 'Path: /request_context_view/')
def test_nested_requests(self):
"""
@@ -1250,6 +1250,7 @@ class RequestMethodStringDataTests(TestCase):
@override_settings(ROOT_URLCONF='test_client_regress.urls',)
class QueryStringTests(TestCase):
+ @ignore_warnings(category=RemovedInDjango19Warning) # `request.REQUEST` is deprecated
def test_get_like_requests(self):
# See: https://code.djangoproject.com/ticket/10571.
for method_name in ('get', 'head'):
@@ -1275,6 +1276,7 @@ class QueryStringTests(TestCase):
self.assertEqual(response.context['request-foo'], None)
self.assertEqual(response.context['request-bar'], 'bang')
+ @ignore_warnings(category=RemovedInDjango19Warning) # `request.REQUEST` is deprecated
def test_post_like_requests(self):
# A POST-like request can pass a query string as data
response = self.client.post("/request_data/", data={'foo': 'whiz'})
diff --git a/tests/test_client_regress/views.py b/tests/test_client_regress/views.py
index b752d1b9f7..28635940ae 100644
--- a/tests/test_client_regress/views.py
+++ b/tests/test_client_regress/views.py
@@ -1,5 +1,4 @@
import json
-import warnings
from django.conf import settings
from django.contrib.auth.decorators import login_required
@@ -40,11 +39,8 @@ get_view = login_required(get_view)
def request_data(request, template='base.html', data='sausage'):
"A simple view that returns the request data in the context"
- # request.REQUEST is deprecated, but needs testing until removed.
- with warnings.catch_warnings(record=True):
- warnings.simplefilter("always")
- request_foo = request.REQUEST.get('foo')
- request_bar = request.REQUEST.get('bar')
+ request_foo = request.REQUEST.get('foo')
+ request_bar = request.REQUEST.get('bar')
return render_to_response(template, {
'get-foo': request.GET.get('foo'),