You may have a module level setting function. According to the nose documentation :
Tested modules offer installation and disassembly at the module level; define a setup method, setup_module , setUp or setUpModule to configure, teardown_module , or tearDownModule to delete.
So, more specifically, for your case:
def setup_module(): print "common_setup" def teardown_module(): print "common_teardown" def test_1(): print "test_1" def test_2(): print "test_2"
Running the test gives you:
$ nosetests common_setup_test.py -s -v common_setup common_setup_test.test_1 ... test_1 ok common_setup_test.test_2 ... test_2 ok common_teardown ---------------------------------------------------------------------- Ran 2 tests in 0.000s OK
It doesn't matter which name you choose, so both setup and setup_module will work the same way, but setup_module has great clarity.
source share