class documentation

class AsyncRequestFactory(RequestFactory): (source)

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 generic Construct an arbitrary HTTP request.
Method request Construct a generic request object.
Method _base_scope The base scope for a request.

Inherited from RequestFactory:

Method __init__ 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
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
def generic(self, method, path, data='', content_type='application/octet-stream', secure=False, **extra): (source)

Construct an arbitrary HTTP request.

def request(self, **request): (source)

Construct a generic request object.

def _base_scope(self, **request): (source)

The base scope for a request.