hmmm, something say like:
def unittests(): """ test the ability to run unittests """ import os import sys import glob import cStringIO from gluon.shell import env #save stdout so we can capture data and reset it. stdout = sys.stdout stderr = sys.stderr #get a list of the modules to test cdir = os.path.join('applications', request.application, 'tests') if not os.path.isdir(cdir): die(errmsg) files = glob.glob(os.path.join(cdir, '*.py')) html = '' test_count = 0 pass_count = 0 fail_count = 0 for testfile in files: test_count += 1 html += '<h2>Running Test "%s.py" ... done.</h2><br/>\n' % testfile # Reload environment before each test. globs = env(request.application, c='default', f='index', import_models=True, extra_request={'test_db':True}) sys.stdout = cStringIO.StringIO() execfile(testfile, globs) report = sys.stdout.getvalue().strip() if report.find('FAIL') >= 0: fail_count += 1 html += '<h3 class="failed">FAILED</h3>\n' html += CODE(report, language='web2py', \ link='/examples/global/vars/').xml() else: pass_count += 1 html += '<h3 class="passed">PASSED</h3>\n' sys.stdout = stdout return dict(html=XML(html), test_count = test_count, pass_count = pass_count, fail_count = fail_count) I'm in the process of creating some functions that will allow me to run some doctests and unittests from the browser on google app engine. the above is the start of my method for unit testing. i think it basically does what bruno suggests, but just not in an interactive shell environment. i'll post a slice when i get my testing tools together. christian