diff options
| author | Carlton Gibson <carlton@noumenal.es> | 2020-11-04 11:07:15 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-11-04 11:07:15 +0100 |
| commit | ebb08d19424c314c75908bc6048ff57c2f872269 (patch) | |
| tree | 8bce4349ce1e49b86a2a1aaf3e440b7abdebf95e /docs | |
| parent | c2d4926702045e342a668057f0a758eec9db9436 (diff) | |
Fixed #32159 -- Ensured AsyncRequestFactory correctly sets headers.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/releases/3.1.4.txt | 3 | ||||
| -rw-r--r-- | docs/topics/testing/tools.txt | 17 |
2 files changed, 18 insertions, 2 deletions
diff --git a/docs/releases/3.1.4.txt b/docs/releases/3.1.4.txt index f8d9752db7..6641b0aaf5 100644 --- a/docs/releases/3.1.4.txt +++ b/docs/releases/3.1.4.txt @@ -11,3 +11,6 @@ Bugfixes * Fixed setting the ``Content-Length`` HTTP header in ``AsyncRequestFactory`` (:ticket:`32162`). + +* Fixed passing extra HTTP headers to ``AsyncRequestFactory`` request methods + (:ticket:`32159`). diff --git a/docs/topics/testing/tools.txt b/docs/topics/testing/tools.txt index d4bdb5157c..2d10873611 100644 --- a/docs/topics/testing/tools.txt +++ b/docs/topics/testing/tools.txt @@ -1810,9 +1810,22 @@ If you are testing from an asynchronous function, you must also use the asynchronous test client. This is available as ``django.test.AsyncClient``, or as ``self.async_client`` on any test. -With the exception of the ``follow`` parameter, which is not supported, ``AsyncClient`` has the same methods and signatures as the synchronous (normal) -test client, but any method that makes a request must be awaited:: +test client, with two exceptions: + +* The ``follow`` parameter is not supported. +* Headers passed as ``extra`` keyword arguments should not have the ``HTTP_`` + prefix required by the synchronous client (see :meth:`Client.get`). For + example, here is how to set an HTTP ``Accept`` header:: + + >>> c = AsyncClient() + >>> c.get( + ... '/customers/details/', + ... {'name': 'fred', 'age': 7}, + ... ACCEPT='application/json' + ... ) + +Using ``AsyncClient`` any method that makes a request must be awaited:: async def test_my_thing(self): response = await self.async_client.get('/some-url/') |
