unit testing

Ben Finney bignose+hates-spam at benfinney.id.au
Sat Oct 6 11:02:34 EDT 2007


Paul Rubin <http://phr.cx@NOSPAM.invalid> writes:

> Ben Finney <bignose+hates-spam at benfinney.id.au> writes:
> > Or even better:
> > 
> >     def test_raises_good_exception():
> >         try:
> >             thingy()
> 
> Well if we're grading on style, maybe you really want to name the
> function 'test_thingy' instead of 'test_raises_good_exception'.

The function is a test case. It should be named for what specific case
it's testing.

A function named "test_thingy" (given the code unit is a function
named "thingy") would be some generic "do *all* the tests for
thingy". That's not a test case; perhaps it's the name of the unit
test module for "thingy".

-- 
 \     "I must have a prodigious quantity of mind; it takes me as much |
  `\          as a week sometimes to make it up."  -- Mark Twain, _The |
_o__)                                                Innocents Abroad_ |
Ben Finney



More information about the Python-list mailing list