Unittest - How do I code lots of simple tests

Emile van Sebille emile at fenx.com
Wed Oct 22 10:19:33 EDT 2003


"Paul Moore" <paul.moore at atosorigin.com> wrote in message
news:182bcf76.0310220344.1853dab at posting.google.com...
> David Goodger <goodger at python.org> wrote in message
news:<mailman.322.1066779769.2192.python-list at python.org>...
> > Paul Moore wrote:
> >  >>> Can anyone suggest a more reasonable way of running this sort of
> >  >>> table-driven test via unittest?
> >
> > Take a look at Docutils' test/DocutilsTestSupport.py for ideas.  The
> > CustomTestSuite and CustomTestCase classes provide support for named
> > data-driven tests.  Most of Docutils' tests are data-driven.
>
> Urk. That's hairy stuff. Thanks for the pointer, I'll do some research.
>
> But I still think that this sort of thing should be easy :-(
>

If you find unnittest too heavy handed, you may want to take a look at
doctest.  Essentially, doctest will test code found in docstrings and
compare results.  This allows you to paste an interactive session into your
module.

HTH,

Emile van Sebille
emile at fenx.com






More information about the Python-list mailing list