class AsyncRequestFactory(RequestFactory):
Known subclasses: django.test.client.AsyncClient
Class that lets you create mock ASGI-like Request objects for use in testing. Usage:
rf = AsyncRequestFactory() get_request = await rf.get('/hello/') post_request = await rf.post('/submit/', {'foo': 'bar'})
Once you have a request object you can pass it to any view function, including synchronous ones. The reason we have a separate class here is: a) this makes ASGIRequest subclasses, and b) AsyncTestClient can subclass it.
Method | _base_scope |
The base scope for a request. |
Method | generic |
Construct an arbitrary HTTP request. |
Method | request |
Construct a generic request object. |
Inherited from RequestFactory
:
Method | __init__ |
Undocumented |
Method | _base_environ |
The base environment for a request. |
Method | _encode_data |
Undocumented |
Method | _encode_json |
Return encoded JSON if data is a dict, list, or tuple and content_type is application/json. |
Method | _get_path |
Undocumented |
Method | delete |
Construct a DELETE request. |
Method | get |
Construct a GET request. |
Method | head |
Construct a HEAD request. |
Method | options |
Construct an OPTIONS request. |
Method | patch |
Construct a PATCH request. |
Method | post |
Construct a POST request. |
Method | put |
Construct a PUT request. |
Method | trace |
Construct a TRACE request. |
Instance Variable | cookies |
Undocumented |
Instance Variable | defaults |
Undocumented |
Instance Variable | errors |
Undocumented |
Instance Variable | json_encoder |
Undocumented |
django.test.client.AsyncClient