[TIP] Using one unit test with different input parameters

Ben Finney ben+python at benfinney.id.au
Tue Jul 22 20:50:01 PDT 2008


"Jonathan Lange" <jml at mumak.net> writes:

> On Sun, Jul 13, 2008 at 12:14 AM, Ben Finney
> <bignose+hates-spam at benfinney.id.au> wrote:
> > I see that 'TestCase.id' is a method provided already by
> > 'unittest.TestCase', and you're overriding it in the generated
> > test case instances.
[…]

> > How are you getting these values at run time? A custom TestRunner
> > class?
> 
> I'll answer for Rob: Yes.

Thanks. It looks like there are more goodies to mine from
bzrlib.tests.

> Answering for myself, unittest uses TestCase,shortDescription in its
> runner, and shortDescription is next to useless.

I've found it erratic, but not useless.

> It will return the docstring of a test if it has one. Seeing the
> docstring in a test run might *sound* like a good idea, but in the
> heat of debugging it's just frustrating.

My experience is quite contrary to this. If one writes docstrings as
one-line synopsis plus multi-line description (as per PEP 257) then
the one-line synopsis is used as the test description. I find this
very useful in practice.

> Bazaar's test runner has a lot of very nice features that I've wanted
> to steal for Twisted for some time. Have a play with it.

Shall do, thanks.

-- 
 \       “The apparent lesson of the Inquisition is that insistence on |
  `\         uniformity of belief is fatal to intellectual, moral, and |
_o__)    spiritual health.” —_The Uses Of The Past_, Herbert J. Muller |
Ben Finney




More information about the testing-in-python mailing list