Fixtures tend to be small and reusable. Given that a specific fixture can rely on other fixtures
@pytest.fixture
def Account(db, memcache):
...
I would like to organize my fixtures in modules, and import them in a specific test-file like so (e.g.)
from .fixtures.models import Account
Unfortunately this does not seem to work. Instead I always have to import all subordinate fixtures too, e.g.
from .fixtures.models import Account, db, memcache
What is the better approach to have fine-grained small, reusable fixtures and make them accessible on a module level. (conftest works on the package/directory level.)
Usually i don't recommend this but if you have modules containing a specific set of fixtures (Which depend on each other), then maybe from .fixtures.models import *
would be workable? I can't think of another generic solution at the moment which would avoid knowing the underlying fixture dependencies in the importing test module.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With