Unittest - How do I code lots of simple tests

Ian Bicking ianb at colorstudy.com
Wed Oct 22 12:37:40 EDT 2003


On Wednesday, October 22, 2003, at 08:05 AM, John J. Lee wrote:
> Ian Bicking <ianb at colorstudy.com> writes:
> [grumbles about unittest]
>
> BTW, Ian, did you notice that somewhere on one of the Zope sites
> there's a reference to your blog entry about this?  Looked like they
> have a unittest.main-replacement.

Yes, I've been experimenting with it.  (For others, the URL is 
http://cvs.zope.org/Zope/test.py ) -- it's a bit hard to figure out, it 
has some documentation but only about how to run the script, not how to 
organize your tests.

After much struggling I've gotten it to run -- it seems picky about 
where you put your tests, and it just ignored my tests until I more 
carefully pointed the script to where they were (but there's several 
ways to point the script to a directory, only --libdir seemed to work 
for me).  I'm still not sure how to specify which tests I want to run 
-- it has some regex control there, which seems like both overkill and 
underkill (I don't need the flexibility of regexes to match modules, 
but I want better ways to indicate specific tests in those modules).  I 
actually *like* the basic interface of unittest.main.

What appealed to me about Zope's test.py was pychecker and pdb options 
(ontop of code coverage, which several frameworks have).  Though once I 
looked at how pychecker is invoked, that's easy to add to any 
framework.  Code coverage is supported by several frameworks -- I added 
it to my own unittest-based tests pretty easily too.  Maybe if I looked 
at pdb it would also be easy enough as well, at which point I may or 
may not find the Zope test.py appealing enough to try to figure out how 
it finds (or does not find) files (though now that I've gotten this 
far...)

--
Ian Bicking | ianb at colorstudy.com | http://blog.ianbicking.org






More information about the Python-list mailing list