[TIP] configure a pytest fixture

oliver oliver.schoenborn at gmail.com
Mon Nov 14 12:23:13 PST 2016

I'd like to define a fixture that returns an object that depends on a
parameter. The following can't work because the "a" parameter is expected
to be another fixture:

def some_fixture(a: int):
      return something that depends on value of a

class TestCase:
    def test_1(self, some_fixture(a=123)):
        use fixture return value for a=123
    def test_2(self, some_fixture(a=456)):
        use fixture return value for a=456

Is my only option the good'ol function call, ie remove the fixture
decorator and just call the some_fixture function from my tests?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20161114/fe51986c/attachment.htm>

More information about the testing-in-python mailing list