mdip...@cs.depaul.edu
unread,Dec 4, 2007, 11:51:38 PM12/4/07Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Gluon Web Framework
If you are looking for a quick way to test you controllers you can do
the following
def example(): ### sample controller
"""
>>> example() ### this is a test
4
"""
return 3
def _test(): ### testing controller
import doctest, gluon.fileutils, sys, StringIO
if not gluon.fileutils.check_credentials(request): raise HTTP(400)
stdout=sys.stdout
sys.stdout=StringIO.StringIO()
print '<pre>'
#### add one line for each controller to test
doctest.run_docstring_examples(example,globals(),True) ### test
example
####
print '</pre>'
s=sys.stdout.getvalue()
sys.stdout=stdout
return dict(report=XML(s))
If (and only if) you are logged in as admin you can access the
function _test in your controller and it will run tests for the
controllers listed, for examples this tests the controller example
doctest.run_docstring_examples(example,globals(),True)
It is not the most elegant solution but you can use with the current
version of gluon.
Massimo