nosetests function names
Thursday, October 21, 2010 at 10:20PM
Stuart Mitchell in nosetests, python

Be careful with function names in tests when using nosetests and python 

Nose tests automatically runs all functions in discovered files with the word test in them. This can bite you if for instance you put a function build_test_smelter used to define some test data for a subclass of TestCase in a _init_.py file. 

As nosetests will run this function as well (without the setUp and tearDown methods, that clean your database) you will end up with two instances of your smelter instead of one. This will not show up it you run the tests in a single file but will show up when you use 

$ bin/nosetests 

from the command line as then it will discover that function in your _init_.py file

Article originally appeared on Stuart Mitchell Consulting (http://www.stuartmitchell.com/).
See website for complete article licensing information.