mirror of
https://github.com/django/django.git
synced 2025-11-25 21:22:14 +00:00
Refs #34074 -- Used headers argument for RequestFactory and Client in docs and tests.
This commit is contained in:
parent
0d3ccf7512
commit
99bd5fb4c2
14 changed files with 113 additions and 74 deletions
|
|
@ -152,7 +152,10 @@ example, the test suite for docs.djangoproject.com includes the following::
|
|||
|
||||
class SearchFormTestCase(TestCase):
|
||||
def test_empty_get(self):
|
||||
response = self.client.get('/en/dev/search/', HTTP_HOST='docs.djangoproject.dev:8000')
|
||||
response = self.client.get(
|
||||
"/en/dev/search/",
|
||||
headers={"host": "docs.djangoproject.dev:8000"},
|
||||
)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
and the settings file includes a list of the domains supported by the project::
|
||||
|
|
|
|||
|
|
@ -682,7 +682,7 @@ a name of :setting:`LANGUAGE_COOKIE_NAME` and a value of the language code::
|
|||
or by including the ``Accept-Language`` HTTP header in the request::
|
||||
|
||||
def test_language_using_header(self):
|
||||
response = self.client.get('/', HTTP_ACCEPT_LANGUAGE='fr')
|
||||
response = self.client.get("/", headers={"accept-language": "fr"})
|
||||
self.assertEqual(response.content, b"Bienvenue sur mon site.")
|
||||
|
||||
More details are in :ref:`how-django-discovers-language-preference`.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue