Pytest fixtures importing

Viewed 674

So let's say I have this scenario:

tests:
    fixtures:
        fix1.py
        fix2.py
        fix3.py

Where there are dependencies between fixtures fix1->fix2->fix3 i.e. fix1.py is defining a fixture that is using a fixture defined in fix2.py etc.

So when I want to use fixture f1 from fix1.py in some_test.py I do it like:

from tests.fixtures.fix1 import f1

But pytest requires me to import all dependencies from fix2 then also from fix3 so import statements in some_test.py are expanding. Even this scenario requires additional imports in some_test.py:

# `fix1.py` src
def fA():
    pass

def fB(fA):
    pass


# `some_test.py` src
from tests.fixtures.fix1 import fA, fB # Instead of just importing fB

Seems kinda redundant to me, anyone has any idea why is this the case?

0 Answers
Related