class documentation

class Client(ClientMixin, RequestFactory):

View In Hierarchy

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
def __init__(self, enforce_csrf_checks=False, raise_request_exception=True, **defaults):
def _handle_redirects(self, response, data='', content_type='', **extra):
Follow any redirects by requesting responses from the server using GET.
def delete(self, path, data='', content_type='application/octet-stream', follow=False, secure=False, **extra):
Send a DELETE request to the server.
def get(self, path, data=None, follow=False, secure=False, **extra):
Request a response from the server using GET.
def head(self, path, data=None, follow=False, secure=False, **extra):
Request a response from the server using HEAD.
def options(self, path, data='', content_type='application/octet-stream', follow=False, secure=False, **extra):
Request a response from the server using OPTIONS.
def patch(self, path, data='', content_type='application/octet-stream', follow=False, secure=False, **extra):
Send a resource to the server using PATCH.
def post(self, path, data=None, content_type=MULTIPART_CONTENT, follow=False, secure=False, **extra):
Request a response from the server using POST.
def put(self, path, data='', content_type='application/octet-stream', follow=False, secure=False, **extra):
Send a resource to the server using PUT.
def request(self, **request):
The master request method. Compose the environment dictionary and pass to the handler, return the result of the handler. Assume defaults for the query environment, which can be overridden using the arguments to the request.
def trace(self, path, data='', follow=False, secure=False, **extra):
Send a TRACE request to the server.
exc_info =
extra =

Undocumented

handler =

Undocumented

raise_request_exception =

Undocumented