Context: python 2.6.5 environment
I am using unittest.defaultTestLoader.loadTestsFromModule(module) to load tests.
However, when the following is loaded, the setUpClass method is not executed.
class MyTest(unittest.TestCase):
foo = None
def test_choice(self):
self.logger.info(' .. %s' % str(Full.foo))
self.assertTrue(1 == 1)
@classmethod
def setUpClass(cls):
logging.warn('setUpClass')
cls.foo = settings.INITIAL
The returned test suites shows that it returned:
<unittest.TestSuite
tests=[<unittest.TestSuite
tests=[<internal.tests.master.MyTest testMethod=test_choice>]>,
Basically under the ‘test’ package, there will be many tests modules. And I want the setUpClass & tearDownClass to work for each test suites. loadTestsFromModule does not satisfy my requirement. Are there other ways to achieve this ?
It works now after I upgraded to use unittest2.