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 crea
setup_done is a class variable, not an instance variable.
You are referencing it as an instance variable:
self.setup_done
But you need to reference it as a class variable:
mySelTest.setup_done
Here's the corrected code:
class mySelTest(unittest.TestCase):
setup_done = False
def setUp(self):
print str(mySelTest.setup_done)
if mySelTest.setup_done:
return
mySelTest.setup_done = True
print str(mySelTest.setup_done)