[Tutor] Unittest not running all test cases

Kent Johnson kent37 at tds.net
Fri Apr 7 21:42:15 CEST 2006


Carroll, Barry wrote:
> Greetings:
> 
> I'm not certain this is the right forum for this question. If not,
please point me to the correct one.
> 
> I am using the unittest module to test a package our team is writing.
> 
I presently have three modules of test cases and a top level module to
run the entire suite. The hierarchy looks like this:

>     testsymgen          top level
>         testsymc39      61 test cases
>         testsym25        44 test cases
>         testsymc93      0 test cases (so far)
> 
> testsymgen is a very simple file.  Here it is:
> 
> import unittest
> from testsymc39 import *
> from testsym25 import *
> from testsymc93 import *
> 
> 
> if __name__=='__main__':
>     unittest.main( )
> 
> Each of the sub-modules runs correctly, but when I run testsymgen,
only 99 test cases are executed. Can anyone tell me why this should
happen. Is there some sort of limit on the number of test cases that can
be run in a batch?

I don't think there is a limit like this. I wonder, do you have any name 
collisions? For example if testsymc39 and testsym25 both contain class 
TestSym then only the second one will run because it will shadow the 
name from the first module.

If this is the case you need a more sophisticated way of accumulating 
tests. You might want to look into using nose or one of the other 
test-discovery frameworks listed here:
http://pycheesecake.org/wiki/PythonTestingToolsTaxonomy#UnitTestingTools

Kent



More information about the Tutor mailing list