[TIP] Hi, beginner nose question
Titus Brown
titus at caltech.edu
Tue Nov 20 03:45:35 PST 2007
-> What if, for functional or integration tests, I want to run some fixture
-> house keeping once *per* class, before and after all that classes tests?
-> Say to store counters and what not in the classes namespace as static
-> variables or class variables? Basically I wish as a naive newbie, that
-> there was a third layer of setup/teardown. I figured out I could:
->
-> - just not put more then one TestClass in a module
-> - use class methods and get setUp and tearDown to call those class
-> methods iff on first or last setup
->
-> Am I missing something or am I trying something that is just bad
-> practice? Is there any reason nose could not permit such a thing?
Iain,
you can use module-level setup/teardown methods:
def setup():
# do things once
def teardown():
# do things once
class TestBlah:
def setup():
# every time a test fn in this class is run
I use this all the time, and it is very convenient!
cheers,
--titus
More information about the testing-in-python
mailing list