[pytest-dev] top-level conftest.py not recognized when running tests in sub-directories

Anatoly Bubenkov bubenkoff at gmail.com
Thu Sep 25 13:09:53 CEST 2014


did you add __init__.py in all folders?

On 25 September 2014 12:35, Jens Hoffmann <jh at solute.de> wrote:

> Hi,
>
>
> we are working with pytest 2.6.2 and I run into a problem with my conftest
> session fixture setup.
>
> My project structure looks something like this:
>
> .
> ├── project
> │ └── module
> │ └── foo.py
> └── test
> ├── conftest.py
> └── module
> └── test_foo.py
>
>
> conftest.py contains a single fixture with scope="session" and
> autouse=True, setting up some database that is needed for every single
> unittest. So also test_foo.py depends on that database setup.
>
> Now some py.test runs:
>
> $ py.test
> => conftest.py called, database setup properly, tests pass
>
> $ py.test test/module
> => tests fail, fixture in conftest.py not executed
>
> $ py.test test/module/test_foo.py
> => tests fail, fixture in conftest.py not executed
>
> $ py.test -k MyTestClassContainedInTestFooDotPy
> => tests fail, fixture in conftest.py not executed
>
>
> Now my question/problem: Are all these outcoms expected behaviour? I hoped
> that all the runs would pass, that is execute my session fixture so that I
> wont need to always run my whole test suite.
>
>
> Thank you for your answer,
> Jens
>
> _______________________________________________
> Pytest-dev mailing list
> Pytest-dev at python.org
> https://mail.python.org/mailman/listinfo/pytest-dev
>



-- 
Anatoly Bubenkov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pytest-dev/attachments/20140925/c3009c41/attachment.html>


More information about the Pytest-dev mailing list