How to organize test cases with PyUnit

Frank Niessink niessink at serc.nl
Fri Jul 26 04:14:27 EDT 2002


Syver Enstad <syver-en+usenet at online.no> wrote:
> 
> donnal at donnal.net (Donnal Walter) writes:
> 
> <snipped>
>> 
>> Yes, from the responses here that does appear to be the conventional
>> way of doing things, so I guess I will continue using unittest this
>> way too. I had thought I might replace my batch files with a
>> TestSuite, but I'm really not complaining about the way it works now.
>> Thanks.
> 
> Btw, here's some code I put in my __init__.py files to run unittest
> for all modules in a package. 

Just another solution: I usually have my tescases in a tests/ 
subdirectory, and use this testall.py script to run them:

----------------------------------------------
#!/usr/bin/env python

import glob

for filename in glob.glob('*Test.py'):
	exec 'from %s import *'%filename[:-3]

if __name__ == '__main__':
	import unittest
	unittest.main()
----------------------------------------------

This also works from unittestgui.py by entering "testall" in the 
textbox.

Cheers, Frank

-- 
[...] just as lunch was at the centre of a man's temporal day, and man's
temporal day could be seen as an analogy for his spiritual life, so Lunch
should (a) be seen as the centre of a man's spiritual life, and (b) be held
in jolly nice restaurants.
	-- Douglas Adams, 'Life, the Universe, and Everything'



More information about the Python-list mailing list