From fc0fa72ff4cdbf5861a366e31cb8bbacd44da22d Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Wed, 12 Feb 2020 15:15:00 -0700 Subject: Fixed #31224 -- Added support for asynchronous views and middleware. This implements support for asynchronous views, asynchronous tests, asynchronous middleware, and an asynchronous test client. --- docs/topics/testing/advanced.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'docs/topics/testing/advanced.txt') diff --git a/docs/topics/testing/advanced.txt b/docs/topics/testing/advanced.txt index a909c5f3d8..8aca92ea36 100644 --- a/docs/topics/testing/advanced.txt +++ b/docs/topics/testing/advanced.txt @@ -67,6 +67,17 @@ The following is a unit test using the request factory:: response = MyView.as_view()(request) self.assertEqual(response.status_code, 200) +AsyncRequestFactory +------------------- + +``RequestFactory`` creates WSGI-like requests. If you want to create ASGI-like +requests, including having a correct ASGI ``scope``, you can instead use +``django.test.AsyncRequestFactory``. + +This class is directly API-compatible with ``RequestFactory``, with the only +difference being that it returns ``ASGIRequest`` instances rather than +``WSGIRequest`` instances. All of its methods are still synchronous callables. + Testing class-based views ========================= -- cgit v1.3