Wow, I'm not sure how or if you are going to be able to run a doctest on a
form in a controller.
Running it in a web2py shell only returns the form:
In [1] : import os
In [2] : execfile(os.path.join(request.folder,'controllers/default.py'))
In [3] : print do_nothing()
{'form': <gluon.html.FORM object at 0x12028c70>}
I cleaned up your code a bit and it works fine:
def do_nothing():
form=FORM('Your name:',
INPUT(_name='name', requires=IS_NOT_EMPTY()),
INPUT(_type='submit'))
if form.accepts(request.vars, session):
response.flash = 'form accepted'
return dict(message='Your name is %s' % (form.vars.name))
elif form.errors:
response.flash = 'form has errors'
else:
response.flash = 'please fill the form'
return dict(form=form)