Updated to test_client_regress to use RedirectView instead of deprecated redirect_to.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@15991 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Russell Keith-Magee 2011-04-02 08:45:06 +00:00
parent 4c468800ee
commit ae5f3e7418
2 changed files with 20 additions and 11 deletions

View File

@ -3,6 +3,7 @@
Regression tests for the Test Client, especially the customized assertions.
"""
import os
import warnings
from django.conf import settings
from django.core.exceptions import SuspiciousOperation
@ -883,6 +884,14 @@ class ResponseTemplateDeprecationTests(TestCase):
Response.template still works backwards-compatibly, but with pending deprecation warning. Refs #12226.
"""
def setUp(self):
self.save_warnings_state()
warnings.filterwarnings('ignore', category=DeprecationWarning,
module='django.test.client')
def tearDown(self):
self.restore_warnings_state()
def test_response_template_data(self):
response = self.client.get("/test_client_regress/request_data/", data={'foo':'whiz'})
self.assertEqual(response.template.__class__, Template)

View File

@ -1,5 +1,5 @@
from django.conf.urls.defaults import *
from django.views.generic.simple import redirect_to
from django.views.generic import RedirectView
import views
urlpatterns = patterns('',
@ -10,22 +10,22 @@ urlpatterns = patterns('',
(r'^request_data_extended/$', views.request_data, {'template':'extended.html', 'data':'bacon'}),
url(r'^arg_view/(?P<name>.+)/$', views.view_with_argument, name='arg_view'),
(r'^login_protected_redirect_view/$', views.login_protected_redirect_view),
(r'^redirects/$', redirect_to, {'url': '/test_client_regress/redirects/further/'}),
(r'^redirects/further/$', redirect_to, {'url': '/test_client_regress/redirects/further/more/'}),
(r'^redirects/further/more/$', redirect_to, {'url': '/test_client_regress/no_template_view/'}),
(r'^redirect_to_non_existent_view/$', redirect_to, {'url': '/test_client_regress/non_existent_view/'}),
(r'^redirect_to_non_existent_view2/$', redirect_to, {'url': '/test_client_regress/redirect_to_non_existent_view/'}),
(r'^redirect_to_self/$', redirect_to, {'url': '/test_client_regress/redirect_to_self/'}),
(r'^circular_redirect_1/$', redirect_to, {'url': '/test_client_regress/circular_redirect_2/'}),
(r'^circular_redirect_2/$', redirect_to, {'url': '/test_client_regress/circular_redirect_3/'}),
(r'^circular_redirect_3/$', redirect_to, {'url': '/test_client_regress/circular_redirect_1/'}),
(r'^redirects/$', RedirectView.as_view(url='/test_client_regress/redirects/further/')),
(r'^redirects/further/$', RedirectView.as_view(url='/test_client_regress/redirects/further/more/')),
(r'^redirects/further/more/$', RedirectView.as_view(url='/test_client_regress/no_template_view/')),
(r'^redirect_to_non_existent_view/$', RedirectView.as_view(url='/test_client_regress/non_existent_view/')),
(r'^redirect_to_non_existent_view2/$', RedirectView.as_view(url='/test_client_regress/redirect_to_non_existent_view/')),
(r'^redirect_to_self/$', RedirectView.as_view(url='/test_client_regress/redirect_to_self/')),
(r'^circular_redirect_1/$', RedirectView.as_view(url='/test_client_regress/circular_redirect_2/')),
(r'^circular_redirect_2/$', RedirectView.as_view(url='/test_client_regress/circular_redirect_3/')),
(r'^circular_redirect_3/$', RedirectView.as_view(url='/test_client_regress/circular_redirect_1/')),
(r'^set_session/$', views.set_session_view),
(r'^check_session/$', views.check_session_view),
(r'^request_methods/$', views.request_methods_view),
(r'^check_unicode/$', views.return_unicode),
(r'^parse_unicode_json/$', views.return_json_file),
(r'^check_headers/$', views.check_headers),
(r'^check_headers_redirect/$', redirect_to, {'url': '/test_client_regress/check_headers/'}),
(r'^check_headers_redirect/$', RedirectView.as_view(url='/test_client_regress/check_headers/')),
(r'^raw_post_data/$', views.raw_post_data),
(r'^request_context_view/$', views.request_context_view),
)