pytest fixtures in a separate directory pytest fixtures in a separate directory python python

pytest fixtures in a separate directory


Please add the following in your conftest.py

  import pytest  pytest_plugins = [   "fixtures.conftest",   "fixtures.fixture_cifs",   "fixtures.fixture_ftp",   "fixtures.fixture_service"  ]

This ensures that all fixtures declared under fixtures/ will be found by pytest

As a note that the respective directories referred to in fixtures.conftest" need to have __init__.py files for the plugins to be loaded by pytest

A similar case can be seen here: https://stackoverflow.com/a/54736237/6655459


Try importing your fixtures in project/conftest.pyif that is what you mean by "wrappers to return an instance"


read here how structure your test.

Your fixture directory doesn't seem to be part of a package (project does not have __init__.py so cannot be imported as project.fixtures either as fixtures as it is not in the path.You can add required dirs in the path in your tests/conftest.py (sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir, "fixtures")) or sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir) depending how how you want import your modules.