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

Wolfgang Schnerring ws at gocept.com
Mon Sep 15 08:21:30 CEST 2014


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! :-).

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?

Thanks for your help,
Wolfgang
-------------- next part --------------
A non-text attachment was scrubbed...
Name: reproduction.tar.gz
Type: application/gzip
Size: 997 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/pytest-dev/attachments/20140915/0d7d04d4/attachment.bin>


More information about the Pytest-dev mailing list