From 720bd81aad14c6dae9fb952686b55bae236f7769 Mon Sep 17 00:00:00 2001
From: Bojan Mihelac <bmihelac@mihelac.org>
Date: Sun, 20 May 2012 17:51:17 +0200
Subject: [PATCH] Add failing tests for #18356
---
.../regressiontests/test_client_regress/models.py | 8 ++++++++
tests/regressiontests/test_client_regress/urls.py | 1 +
tests/regressiontests/test_client_regress/views.py | 12 ++++++++++++
3 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/tests/regressiontests/test_client_regress/models.py b/tests/regressiontests/test_client_regress/models.py
index 4f057b9..e307feb 100644
a
|
b
|
class ContextTests(TestCase):
|
711 | 711 | finally: |
712 | 712 | django.template.context._standard_context_processors = None |
713 | 713 | |
| 714 | def test_nested_requests(self): |
| 715 | """ |
| 716 | response.context is not lost when view call another view. |
| 717 | """ |
| 718 | response = self.client.get("/test_client_regress/nested_view/") |
| 719 | self.assertEqual(response.context.__class__, Context) |
| 720 | self.assertEqual(response.context['nested'], 'yes') |
| 721 | |
714 | 722 | |
715 | 723 | @override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',)) |
716 | 724 | class SessionTests(TestCase): |
diff --git a/tests/regressiontests/test_client_regress/urls.py b/tests/regressiontests/test_client_regress/urls.py
index d869c23..193d5f4 100644
a
|
b
|
urlpatterns = patterns('',
|
13 | 13 | (r'^request_data/$', views.request_data), |
14 | 14 | (r'^request_data_extended/$', views.request_data, {'template':'extended.html', 'data':'bacon'}), |
15 | 15 | url(r'^arg_view/(?P<name>.+)/$', views.view_with_argument, name='arg_view'), |
| 16 | url(r'^nested_view/$', views.nested_view, name='nested_view'), |
16 | 17 | (r'^login_protected_redirect_view/$', views.login_protected_redirect_view), |
17 | 18 | (r'^redirects/$', RedirectView.as_view(url='/test_client_regress/redirects/further/')), |
18 | 19 | (r'^redirects/further/$', RedirectView.as_view(url='/test_client_regress/redirects/further/more/')), |
diff --git a/tests/regressiontests/test_client_regress/views.py b/tests/regressiontests/test_client_regress/views.py
index ab625a9..8b71c53 100644
a
|
b
|
from django.utils.encoding import smart_str
|
9 | 9 | from django.core.serializers.json import DjangoJSONEncoder |
10 | 10 | from django.test.client import CONTENT_TYPE_RE |
11 | 11 | from django.template import RequestContext |
| 12 | from django.test import Client |
| 13 | from django.test.utils import setup_test_environment |
| 14 | |
12 | 15 | |
13 | 16 | def no_template_view(request): |
14 | 17 | "A simple view that expects a GET request, and returns a rendered template" |
… |
… |
def view_with_argument(request, name):
|
50 | 53 | else: |
51 | 54 | return HttpResponse('Howdy, %s' % name) |
52 | 55 | |
| 56 | def nested_view(request): |
| 57 | """ |
| 58 | A view that uses test client to call another view. |
| 59 | """ |
| 60 | setup_test_environment() |
| 61 | c = Client() |
| 62 | c.get("/test_client_regress/no_template_view") |
| 63 | return render_to_response('base.html', {'nested':'yes'}) |
| 64 | |
53 | 65 | def login_protected_redirect_view(request): |
54 | 66 | "A view that redirects all requests to the GET view" |
55 | 67 | return HttpResponseRedirect('/test_client_regress/get_view/') |