class documentation

class AsyncRequestFactory(RequestFactory):

Known subclasses: django.test.client.AsyncClient

View In Hierarchy

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
def _base_scope(self, **request):
The base scope for a request.
def generic(self, method, path, data='', content_type='application/octet-stream', secure=False, **extra):
Construct an arbitrary HTTP request.
def request(self, **request):
Construct a generic request object.