summaryrefslogtreecommitdiff
path: root/tests/view_tests
diff options
context:
space:
mode:
authoryushanfans2233 <yushanfans2233@qq.com>2023-11-11 15:24:24 +0800
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2023-12-04 10:52:06 +0100
commit14b0132e5e70854076ea781451f5ff37f8dc8edd (patch)
tree698a7483db22596df73a9535bb79ebf0fc6763c7 /tests/view_tests
parent8fcb9f1f106cf60d953d88aeaa412cc625c60029 (diff)
Fixed #34830 -- Added request to bad_request/csrf_failure view template contexts.
Diffstat (limited to 'tests/view_tests')
-rw-r--r--tests/view_tests/tests/test_csrf.py1
-rw-r--r--tests/view_tests/tests/test_defaults.py23
2 files changed, 24 insertions, 0 deletions
diff --git a/tests/view_tests/tests/test_csrf.py b/tests/view_tests/tests/test_csrf.py
index ef4a50dd45..af16ffd740 100644
--- a/tests/view_tests/tests/test_csrf.py
+++ b/tests/view_tests/tests/test_csrf.py
@@ -112,6 +112,7 @@ class CsrfViewTests(SimpleTestCase):
"""A custom CSRF_FAILURE_TEMPLATE_NAME is used."""
response = self.client.post("/")
self.assertContains(response, "Test template for CSRF failure", status_code=403)
+ self.assertIs(response.wsgi_request, response.context.request)
def test_custom_template_does_not_exist(self):
"""An exception is raised if a nonexistent template is supplied."""
diff --git a/tests/view_tests/tests/test_defaults.py b/tests/view_tests/tests/test_defaults.py
index f99066e5bb..415a9a8c67 100644
--- a/tests/view_tests/tests/test_defaults.py
+++ b/tests/view_tests/tests/test_defaults.py
@@ -111,6 +111,29 @@ class DefaultsTests(TestCase):
(
"django.template.loaders.locmem.Loader",
{
+ "400.html": (
+ "This is a test template for a 400 error "
+ ),
+ },
+ ),
+ ],
+ },
+ }
+ ]
+ )
+ def test_custom_bad_request_template(self):
+ response = self.client.get("/raises400/")
+ self.assertIs(response.wsgi_request, response.context[-1].request)
+
+ @override_settings(
+ TEMPLATES=[
+ {
+ "BACKEND": "django.template.backends.django.DjangoTemplates",
+ "OPTIONS": {
+ "loaders": [
+ (
+ "django.template.loaders.locmem.Loader",
+ {
"404.html": (
"This is a test template for a 404 error "
"(path: {{ request_path }}, "