1
0
mirror of https://github.com/django/django.git synced 2025-10-23 21:59:11 +00:00

Refs #34074 -- Used headers argument for RequestFactory and Client in docs and tests.

This commit is contained in:
David Wobrock
2022-12-24 00:10:25 +01:00
committed by Mariusz Felisiak
parent 0d3ccf7512
commit 99bd5fb4c2
14 changed files with 113 additions and 74 deletions

View File

@@ -1228,14 +1228,18 @@ class UploadedFileEncodingTest(SimpleTestCase):
class RequestHeadersTest(SimpleTestCase):
def test_client_headers(self):
"A test client can receive custom headers"
response = self.client.get("/check_headers/", HTTP_X_ARG_CHECK="Testing 123")
response = self.client.get(
"/check_headers/", headers={"x-arg-check": "Testing 123"}
)
self.assertEqual(response.content, b"HTTP_X_ARG_CHECK: Testing 123")
self.assertEqual(response.status_code, 200)
def test_client_headers_redirect(self):
"Test client headers are preserved through redirects"
response = self.client.get(
"/check_headers_redirect/", follow=True, HTTP_X_ARG_CHECK="Testing 123"
"/check_headers_redirect/",
follow=True,
headers={"x-arg-check": "Testing 123"},
)
self.assertEqual(response.content, b"HTTP_X_ARG_CHECK: Testing 123")
self.assertRedirects(