doctests for interactive functions
Ben Finney
bignose+hates-spam at benfinney.id.au
Thu Feb 8 16:03:29 EST 2007
Brian van den Broek <broek at cc.umanitoba.ca> writes:
> Since the classes are for getting input interactively, a
> straightforward use of doctest is not going to work. (The tests
> won't run automatically.) I've come up with a way to make it work,
> but I would like to know from more experienced people if there are
> better ways that I am overlooking.
One suggestion I can give is to decouple the task of "get input from
the user" and "validate this value against particular criteria". The
former should be so simple and *stupid* in its implementation that
very little can go wrong. The latter should be each of your validation
classes, or some re-implementation of them, that is non-interactive
and therefore easy to test.
Then, the application simply uses these building blocks (that are now
well-tested and reliable) to do what it does: get input, then validate
that input, and possible ask for input again.
--
\ "How many people here have telekenetic powers? Raise my hand." |
`\ -- Emo Philips |
_o__) |
Ben Finney
More information about the Python-list
mailing list