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.
|
__init__(self,
enforce_csrf_checks=False,
**defaults)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature |
source code
|
|
|
store_exc_info(self,
**kwargs)
Stores exceptions when they are generated by a view. |
source code
|
|
|
_session(self)
Obtains the current session variables. |
source code
|
|
|
session(self)
Obtains the current session variables. |
source code
|
|
|
|
|
get(self,
path,
data={},
follow=False,
**extra)
Requests a response from the server using GET. |
source code
|
|
|
post(self,
path,
data={},
content_type=MULTIPART_CONTENT,
follow=False,
**extra)
Requests a response from the server using POST. |
source code
|
|
|
head(self,
path,
data={},
follow=False,
**extra)
Request a response from the server using HEAD. |
source code
|
|
|
options(self,
path,
data={},
follow=False,
**extra)
Request a response from the server using OPTIONS. |
source code
|
|
|
put(self,
path,
data={},
content_type=MULTIPART_CONTENT,
follow=False,
**extra)
Send a resource to the server using PUT. |
source code
|
|
|
delete(self,
path,
data={},
follow=False,
**extra)
Send a DELETE request to the server. |
source code
|
|
|
login(self,
login,
password,
server_id=1,
secure=True)
Sets the Factory to appear as if it has successfully logged into a
site. |
source code
|
|
|
logout(self)
Removes the authenticated user's cookies and session object. |
source code
|
|
|
_handle_redirects(self,
response,
**extra)
Follows any redirects by requesting responses from the server using
GET. |
source code
|
|
Inherited from object :
__delattr__ ,
__format__ ,
__getattribute__ ,
__hash__ ,
__new__ ,
__reduce__ ,
__reduce_ex__ ,
__repr__ ,
__setattr__ ,
__sizeof__ ,
__str__ ,
__subclasshook__
|