Module webtest
source code
Extensions to unittest for web frameworks.
Use the WebCase.getPage method to request a page from your HTTP
server.
Framework Integration
If you have control over your server process, you can handle errors
in the server-side of the HTTP conversation a bit better. You must run
both the client (your WebCase tests) and the server in the same process
(but in separate threads, obviously).
When an error occurs in the framework, call server_error. It will
print the traceback to stdout, and keep any assertions you have from
running (the assumption is that, if the server errors, the page output
will not be of further significance to your tests).
|
|
|
|
|
cleanHeaders(headers,
method,
body,
host,
port)
Return request headers, with required headers added (if missing). |
source code
|
|
|
shb(response)
Return status, headers, body the way we like from a response. |
source code
|
|
|
openURL(url,
headers=None,
method=' GET ' ,
body=None,
host=' 127.0.0.1 ' ,
port=8000,
http_conn=<class httplib.HTTPConnection at 0xf702c65c>,
protocol=' HTTP/1.1 ' )
Open the given HTTP resource and return status, headers, and body. |
source code
|
|
|
|
|
methods_with_bodies = ( ' POST ' , ' PUT ' )
|
|
ignored_exceptions = [ ]
|
|
ignore_all = False
|
|
__package__ = ' cherrypy.test '
|
Return an IP address for a client connection given the server
host.
If the server is listening on '0.0.0.0' (INADDR_ANY) or '::'
(IN6ADDR_ANY), this will return the proper localhost.
|
Server debug hook. Return True if exception handled, False if
ignored.
You probably want to wrap this, so you can still handle an error using
your framework when it's ignored.
|