class Client(ClientMixin, RequestFactory):
A class that can act as a client for testing purposes.
It allows the user to compose GET and POST requests, and obtain the response that the server gave to those requests. The server Response objects are annotated with the details of the contexts and templates that were rendered during the process of serving the request.
Client objects are stateful - they will retain cookie (and thus session) details for the lifetime of the Client instance.
This is not intended as a replacement for Twill/Selenium or the like - it is here to allow testing against the contexts and templates produced by a view, rather than the HTML rendered to the end-user.
Method | __init__ |
Undocumented |
Method | _handle_redirects |
Follow any redirects by requesting responses from the server using GET. |
Method | delete |
Send a DELETE request to the server. |
Method | get |
Request a response from the server using GET. |
Method | head |
Request a response from the server using HEAD. |
Method | options |
Request a response from the server using OPTIONS. |
Method | patch |
Send a resource to the server using PATCH. |
Method | post |
Request a response from the server using POST. |
Method | put |
Send a resource to the server using PUT. |
Method | request |
No summary |
Method | trace |
Send a TRACE request to the server. |
Instance Variable | exc_info |
Undocumented |
Instance Variable | extra |
Undocumented |
Instance Variable | handler |
Undocumented |
Instance Variable | raise_request_exception |
Undocumented |
Inherited from ClientMixin
:
Method | _login |
Undocumented |
Method | _parse_json |
Undocumented |
Method | check_exception |
Look for a signaled exception, clear the current context exception data, re-raise the signaled exception, and clear the signaled exception from the local cache. |
Method | force_login |
Undocumented |
Method | login |
Set the Factory to appear as if it has successfully logged into a site. |
Method | logout |
Log out the user by removing the cookies and session object. |
Method | store_exc_info |
Store exceptions when they are generated by a view. |
Instance Variable | cookies |
Undocumented |
Property | session |
Return the current session variables. |
Inherited from RequestFactory
:
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 | generic |
Construct an arbitrary HTTP request. |
Instance Variable | cookies |
Undocumented |
Instance Variable | defaults |
Undocumented |
Instance Variable | errors |
Undocumented |
Instance Variable | json_encoder |
Undocumented |
Undocumented
django.test.client.RequestFactory.delete
django.test.client.RequestFactory.get
django.test.client.RequestFactory.head
django.test.client.RequestFactory.patch
django.test.client.RequestFactory.post
django.test.client.RequestFactory.put
django.test.client.RequestFactory.trace