diff -r f38db5003acc tests/regressiontests/test_client_regress/models.py
a
|
b
|
|
9 | 9 | from django.core.urlresolvers import reverse |
10 | 10 | from django.template import (TemplateDoesNotExist, TemplateSyntaxError, |
11 | 11 | Context, Template, loader) |
| 12 | import django.template.context |
12 | 13 | from django.test import Client, TestCase |
13 | 14 | from django.test.client import encode_file |
14 | 15 | from django.test.utils import ContextList |
… |
… |
|
648 | 649 | except KeyError, e: |
649 | 650 | self.assertEquals(e.args[0], 'does-not-exist') |
650 | 651 | |
| 652 | def test_15368(self): |
| 653 | # Need to insert a context processor that assumes certain things about |
| 654 | # the request instance. This triggers a bug caused by some ways of |
| 655 | # copying RequestContext. |
| 656 | try: |
| 657 | django.template.context._standard_context_processors = (lambda request: {'path': request.special_path},) |
| 658 | response = self.client.get("/test_client_regress/request_context_view/") |
| 659 | self.assertContains(response, 'Path: /test_client_regress/request_context_view/') |
| 660 | finally: |
| 661 | django.template.context._standard_context_processors = None |
| 662 | |
651 | 663 | |
652 | 664 | class SessionTests(TestCase): |
653 | 665 | fixtures = ['testdata.json'] |
diff -r f38db5003acc tests/regressiontests/test_client_regress/templates/request_context.html
diff -r f38db5003acc tests/regressiontests/test_client_regress/urls.py
a
|
b
|
|
27 | 27 | (r'^check_headers/$', views.check_headers), |
28 | 28 | (r'^check_headers_redirect/$', redirect_to, {'url': '/test_client_regress/check_headers/'}), |
29 | 29 | (r'^raw_post_data/$', views.raw_post_data), |
| 30 | (r'^request_context_view/$', views.request_context_view), |
30 | 31 | ) |
diff -r f38db5003acc tests/regressiontests/test_client_regress/views.py
a
|
b
|
|
7 | 7 | from django.utils.encoding import smart_str |
8 | 8 | from django.core.serializers.json import DjangoJSONEncoder |
9 | 9 | from django.test.client import CONTENT_TYPE_RE |
| 10 | from django.template import RequestContext |
10 | 11 | |
11 | 12 | def no_template_view(request): |
12 | 13 | "A simple view that expects a GET request, and returns a rendered template" |
… |
… |
|
94 | 95 | def raw_post_data(request): |
95 | 96 | "A view that is requested with GET and accesses request.raw_post_data. Refs #14753." |
96 | 97 | return HttpResponse(request.raw_post_data) |
| 98 | |
| 99 | def request_context_view(request): |
| 100 | # Special attribute that won't be present on a plain HttpRequest |
| 101 | request.special_path = request.path |
| 102 | return render_to_response('request_context.html', context_instance=RequestContext(request, {})) |