My Python version is 2.6.
I would like to execute the test setUp method only once since I do things there which are needed for all tests.
My idea was to create a boolean variable which will be set to 'true' after the first execution and then disable more than one call to the setup method.
class mySelTest(unittest.TestCase):
setup_done = False
def setUp(self):
print str(self.setup_done)
if self.setup_done:
return
self.setup_done = True
print str(self.setup_done)
The output:
False
True
--- Test 1 ---
False
True
--- Test 2 ---
why is this not working? Did I miss anything?