[mod_python] Unit testing in mod_python

Mike Looijmans nlv11281 at natlab.research.philips.com
Tue Jan 10 04:24:41 EST 2006

I did something like that to emulate a mod_python environment when the
host was actually running CGI. This gave max performance on our main
sites, while the one site running CGI could still use the same scripts.
The extra code/overhead needed to emulate mod_python was much less than 
the performance penalty that cgihandler would impose on the scripts.

I'll dig up the code.

Basically, it just created a "request" object like this:

class Request:
	def __init__(self):
	def write(self, data):

I just added extra fields/methods to the Request emulator 'on demand',
by just running the site in CGI and see what fails.

Mike Looijmans
Philips Natlab / Topic Automation

Sebastjan Trepca wrote:
> Hi,
> does anyone know of any mod_python unittest module which could generate 
> a "fake request" so you could effectivly test your handlers?
> For example:
> import my_handler
> fake_request = get_basic_request(qs="test1=1&test2=2")
> assert my_handler.handle(fake_request)==apache.OK
> assert fake_request.out.startswith('<html>')
> Thanks, Sebastjan
> ------------------------------------------------------------------------
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python

More information about the Mod_python mailing list