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

Bruno Oliveira nicoddemus at gmail.com
Mon Jan 19 13:09:10 CET 2015


Hi Floris,

Thanks for the response and clarification, I'm following the approach you
suggested and it's working fine.

Cheers,
Bruno.

On Sun, Jan 18, 2015 at 7:42 AM, Floris Bruynooghe <flub at devork.be> wrote:

> 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/20150119/ec015692/attachment.html>


More information about the pytest-dev mailing list