summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_client_regress/tests.py8
-rw-r--r--tests/test_client_regress/urls.py1
-rw-r--r--tests/test_client_regress/views.py13
3 files changed, 21 insertions, 1 deletions
diff --git a/tests/test_client_regress/tests.py b/tests/test_client_regress/tests.py
index 67e66fa52d..857d6d83c0 100644
--- a/tests/test_client_regress/tests.py
+++ b/tests/test_client_regress/tests.py
@@ -925,6 +925,14 @@ class ContextTests(TestCase):
finally:
django.template.context._standard_context_processors = None
+ def test_nested_requests(self):
+ """
+ response.context is not lost when view call another view.
+ """
+ response = self.client.get("/test_client_regress/nested_view/")
+ self.assertEqual(response.context.__class__, Context)
+ self.assertEqual(response.context['nested'], 'yes')
+
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
class SessionTests(TestCase):
diff --git a/tests/test_client_regress/urls.py b/tests/test_client_regress/urls.py
index 6a0b330e02..1bde10315d 100644
--- a/tests/test_client_regress/urls.py
+++ b/tests/test_client_regress/urls.py
@@ -11,6 +11,7 @@ urlpatterns = patterns('',
(r'^request_data/$', views.request_data),
(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'),
+ url(r'^nested_view/$', views.nested_view, name='nested_view'),
(r'^login_protected_redirect_view/$', views.login_protected_redirect_view),
(r'^redirects/$', RedirectView.as_view(url='/test_client_regress/redirects/further/')),
(r'^redirects/further/$', RedirectView.as_view(url='/test_client_regress/redirects/further/more/')),
diff --git a/tests/test_client_regress/views.py b/tests/test_client_regress/views.py
index 71e5b526e5..d7c54cf2f7 100644
--- a/tests/test_client_regress/views.py
+++ b/tests/test_client_regress/views.py
@@ -5,8 +5,10 @@ from django.contrib.auth.decorators import login_required
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render_to_response
from django.core.serializers.json import DjangoJSONEncoder
-from django.test.client import CONTENT_TYPE_RE
from django.template import RequestContext
+from django.test import Client
+from django.test.client import CONTENT_TYPE_RE
+from django.test.utils import setup_test_environment
class CustomTestException(Exception):
@@ -52,6 +54,15 @@ def view_with_argument(request, name):
else:
return HttpResponse('Howdy, %s' % name)
+def nested_view(request):
+ """
+ A view that uses test client to call another view.
+ """
+ setup_test_environment()
+ c = Client()
+ c.get("/test_client_regress/no_template_view")
+ return render_to_response('base.html', {'nested':'yes'})
+
def login_protected_redirect_view(request):
"A view that redirects all requests to the GET view"
return HttpResponseRedirect('/test_client_regress/get_view/')