nose2 icon indicating copy to clipboard operation
nose2 copied to clipboard

TestCase with only generator method does not run any fixtures

Open jpellerin opened this issue 13 years ago • 3 comments

... at least, not until the generator starts generating tests. This means you can't use setupClass to populate a list that several generator tests use.

jpellerin avatar Jun 27 '12 19:06 jpellerin

Is this still relevant? Is it a bug? Can you point me to where exactly it should be fixed?

thedrow avatar Jul 18 '13 21:07 thedrow

I think this is related to #80, or to the cause of #80, which is the way the generators plugin generates tests. It should work like the parameters plugin -- generate new methods on the test case instance and let the normal testcase loader plugin collect them. That should solve all of these issues that derive from generator test cases being attached to the wrong testcase instance.

jpellerin avatar Jul 19 '13 13:07 jpellerin

I resolved this issue creating the class variables (fixtures) in the class directly instead of in the setUpClass method. eg:


class TestAvro(unittest.TestCase):
    products = json.load(open('products.json'))
    contents = json.load(open('contents.json'))
    @classmethod
    def setUpClass(cls):
        pass

... test with yield

lucagiove avatar Jan 24 '18 18:01 lucagiove