[Baypiggies] Question about unittest, setUp and suites
herbert at albinen.com
Mon May 4 20:29:26 CEST 2009
Long time lurker with a simple question about unittest. I have googled around
and have not really found a good answer to the following question. How do I
define a _setUp_ that only get's called before a suite of tests is run?
(_not_ for every test)
Unittest talks about running a test fixture for a test or a number of
tests but I cannot seem to get this to work for me...
The best solution I could come up with was to do something like this:
ran_suite_setup = False
if ran_suite_setup is False:
print "Running Suite Setup"
ran_suite_setup = True
print 'Doing some test setup'
print 'Hi, I am test1'
print 'Hi, I am test2'
if __name__ == '__main__':
I am not crazy about using globals :) Is this right, or is there a better way
to do this? Any ideas are very appreciated.
More information about the Baypiggies