[pytest-dev] Fixtures not being found when module is named "conftest"

Floris Bruynooghe flub at devork.be
Sun Jan 18 10:42:48 CET 2015


Hi Bruno,

On 2 Jan 2015 14:11, "Bruno Oliveira" <nicoddemus at gmail.com> wrote:
> In my case, I would like to reuse fixtures defined in conftest files
between different projects.
> 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?

I would say so indeed. If you need to share fixtures between projects then
I would create a 3rd project which provides a the plugin under a name.

The contest.py files are meant for within a single project/directory
structure and personally I frown upon any manual importing or otherwise
loading them. They ought to be strictly related to their location so once
you need to start importing them or loading them as a plugin explicitly it
is a sign to me that the code is in the wrong place.

Regards,
Floris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pytest-dev/attachments/20150118/0e623d00/attachment.html>


More information about the pytest-dev mailing list