Package cherrypy :: Package test :: Module webtest
[hide private]
[frames] | no frames]

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).

Classes [hide private]
  TerseTestResult
  TerseTestRunner
A test runner class that displays results in textual form.
  ReloadingTestLoader
  WebCase
  ServerError
Functions [hide private]
 
getchar() source code
 
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 0x85423ec>, protocol='HTTP/1.1')
Open the given HTTP resource and return status, headers, and body.
source code
 
server_error(exc=None)
Server debug hook.
source code
Variables [hide private]
  methods_with_bodies = ('POST', 'PUT')
  ignored_exceptions = []
  ignore_all = False
  __package__ = 'cherrypy.test'
Function Details [hide private]

server_error(exc=None)

source code 

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.