pytest fixtures inside or outside class?

user1456435 picture user1456435 · Mar 2, 2015 · Viewed 7.5k times · Source

What is the difference if the fixture is inside or outside of Class(bla0, bla1)?

@pytest.fixtures()
    def bla0()
    ...

class MyTest:
    @pytest.fixtures()
    def bla1()
        ...

    @pytest.mark.usefixtures("bla0", "bla1")
    def test ...

Answer

Bruno Oliveira picture Bruno Oliveira · Mar 2, 2015

Just a matter of visibility... bla1 can only be used in test methods declared in MyTest.