[pytest-dev] conftest.py ordering depends on the current directory?

holger krekel holger at merlinux.eu
Mon Sep 15 12:47:57 CEST 2014


Hi Wolfgang,

On Mon, Sep 15, 2014 at 08:21 +0200, Wolfgang Schnerring wrote:
> Hi,
> 
> if you have a nested module structure with nested conftest files
> that (re)define the same fixture name, my expectation is that the
> definition of the "closest" conftest file is used -- and usually this
> works fine (yay! :-).

so far so good :)

> For example (please see the attached tarball), if
>     * something/conftest.py defines fixture "one" as 1
>     * something/submodule/conftest.py defines fixture "one" as 2
> then I think this should mean that tests in
>     * something and something/tests should get "1", while
>     * something/submodule and something/submodule/tests should get "2"
> 
> However, this seems to depend on the current working directory or
> something. If the py.test binary is in another directory, say next to
> the sources, then:
>     * "cd ..; py.test package" works, while
>     * "py.test ../package" does not
> (You can try these with the attached tarball by going into the runner
> directory and calling "make working" or "make notworking").
> 
> Can somebody tell me what's going on here? Is this intentional? Am I
> missing something?

You win :) It's a real bug and thanks for the replicatable example.
I fixed it here https://bitbucket.org/hpk42/pytest/pull-request/202/fix-conftest-related-fixture-visibility/diff
and you can install it with::

    pip install --pre -U -i https://devpi.net/hpk/dev/ pytest

best,
holger


More information about the Pytest-dev mailing list