Open fophillips opened 11 years ago
The issue here is that setup is not called until the check function from the generator is going to be run. What you're suggesting is that nose should call setup()
before running the generator, and I don't think that's wise. Generators need to be iterated through to get test counts and formulate test cases.
If you want to variables like self.n
, you should put it into setupClass()
:
from nose.tools import *
class TestSomeStuff:
@classmethod
def setupClass(cls):
cls.n = 10
def setup(self):
self.foo = "bar"
def test_one_thing(self):
assert_equal(self.foo, "bar")
def test_five_things(self):
for _ in range(5):
yield(self.check_one_thing)
def test_n_things(self):
for _ in range(self.n):
yield(self.check_one_thing)
def check_one_thing(self):
assert_equal(self.foo, "bar")
This will work as expected.
What about for the tearDown method?
What about for the tearDown method?
I don't understand what you are asking for.
How to reproduce
Expected behaviour All tests pass
Actual behaviour
Platform and version OS X 10.8.4
More information https://gist.github.com/fophillips/6719447