<div dir="ltr">Hi everyone!<div><br></div><div>Suppose the following files:</div><div><br></div><div># foo/conftest.py</div><div><div>import pytest</div><div>@pytest.fixture</div><div>def my_fixture():</div><div>    return 1 </div></div><div><br></div><div># foo/__init__.py</div><div><empty file></div><div><br></div><div># bar/conftest.py</div><div>pytest_plugins = ['foo.conftest']</div><div><br></div><div># bar/test_bar.py</div><div><div>def test_it(my_fixture):</div><div>    assert my_fixture == 1 </div></div><div><br></div><div>Supposing your PYTHONPATH is configured so you can import "foo.conftest", running "py.test bar" fails because it does not find "my_fixture".</div><div><br></div><div>However, if you rename "foo/conftest.py" to something else like "foo/plugin.py" and update the reference in "bar/conftest.py", then pytest is able to find "my_fixture".</div><div><br></div><div>Looking at the code, I see that there is a special case for "conftest.py" files in _pytest.python, line 1617. I was wondering what is the rationale behind this? I was under the impression that "conftest.py" files where simply plugins which were loaded automatically based on their relative location to the tests.</div><div><br></div><div>In my case, I would like to reuse fixtures defined in conftest files between different projects. </div><div>For instance, project2 depends on project1's fixtures which are defined in a conftest file, so I would like to simply add a "pytest_plugins = ['project1.conftest']" to project2's own conftest file. If I understand correctly, I would have to move project1's fixture to a different file, say "project1.plugin", and reference it in both project1 and project2's conftest files. Is this the recommended approach? </div><div><br></div><div>Cheers,</div><div>Bruno</div></div>