diff --git a/tests/regressiontests/test_client_regress/models.py b/tests/regressiontests/test_client_regress/models.py index b24032d0e9..12e4500a17 100644 --- a/tests/regressiontests/test_client_regress/models.py +++ b/tests/regressiontests/test_client_regress/models.py @@ -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) diff --git a/tests/regressiontests/test_client_regress/urls.py b/tests/regressiontests/test_client_regress/urls.py index 162befe73e..121f4df638 100644 --- a/tests/regressiontests/test_client_regress/urls.py +++ b/tests/regressiontests/test_client_regress/urls.py @@ -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.+)/$', 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), )