I'd like to run a doctest that simulates submitting a form, how would that
look?

Here's my trivial example:

def do_nothing():
    '''
       >>> request.vars.text = 'earafae faefaf afeaf aefafeaef'
        >>> do_nothing()
        'I'm doing nothing'
    '''
    form=FORM('Your name:',
              TEXTAREA(_name='text', requires=IS_NOT_EMPTY()),
              INPUT(_type='submit'))
    if form.accepts(request.vars, session):
        response.flash = 'form accepted'
        response.flash = """I'm doing nothing"""
        return dict(message="""I'm doing nothing""")
    elif form.errors:
        response.flash = 'form has errors'
    else:
        response.flash = 'please fill the form'
    return dict(form=form)


So far my doctest looks like this, but of course, it fails as it never
submits the form at any point and thus goes all the way down to final return
statement instead of return "I'm doing nothing".

Reply via email to