From 67da22f08e05018ea968fcacbac9ac37ea925d85 Mon Sep 17 00:00:00 2001 From: David Wobrock Date: Sun, 9 Oct 2022 22:33:35 +0200 Subject: Fixed #34074 -- Added headers argument to RequestFactory and Client classes. --- docs/releases/4.2.txt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'docs/releases') diff --git a/docs/releases/4.2.txt b/docs/releases/4.2.txt index 39cf05f23b..3951a617e0 100644 --- a/docs/releases/4.2.txt +++ b/docs/releases/4.2.txt @@ -279,6 +279,22 @@ Tests * The :option:`test --debug-sql` option now formats SQL queries with ``sqlparse``. +* The :class:`~django.test.RequestFactory`, + :class:`~django.test.AsyncRequestFactory`, :class:`~django.test.Client`, and + :class:`~django.test.AsyncClient` classes now support the ``headers`` + parameter, which accepts a dictionary of header names and values. This allows + a more natural syntax for declaring headers. + + .. code-block:: python + + # Before: + self.client.get("/home/", HTTP_ACCEPT_LANGUAGE="fr") + await self.async_client.get("/home/", ACCEPT_LANGUAGE="fr") + + # After: + self.client.get("/home/", headers={"accept-language": "fr"}) + await self.async_client.get("/home/", headers={"accept-language": "fr"}) + URLs ~~~~ -- cgit v1.3