Skip to content

Mixing relative and absolute paths to tests fails pytest.ini lookup #949

Closed
@peterlauri

Description

@peterlauri

Please see the below simple reproduction of the problem. When mixing relative and absolute path configuration file resolution as per https://pytest.org/latest/customize.html

First execution just relative path (finds pytest.ini)
Second execution with relative and absolute (does not find pytest.ini)
Third execution with argument -s between relative and absolute path (does find pytest.ini)... strange...

➜  plauri@Peters-MacBook-Pro pytest-abs-rel-bug  ls -lrt dir1 dir2
dir1:
total 16
-rw-r--r--  1 plauri  staff   23 Aug 19 14:34 pytest.ini
-rw-r--r--  1 plauri  staff   35 Aug 19 14:36 test_hello.py
drwxr-xr-x  3 plauri  staff  102 Aug 19 14:37 __pycache__

dir2:
total 8
-rw-r--r--  1 plauri  staff   35 Aug 19 14:37 test_hola.py
drwxr-xr-x  3 plauri  staff  102 Aug 19 14:38 __pycache__
➜  plauri@Peters-MacBook-Pro pytest-abs-rel-bug  cat dir1/pytest.ini
[pytest]
addopts = -vv
➜  plauri@Peters-MacBook-Pro pytest-abs-rel-bug  cd dir1
➜  plauri@Peters-MacBook-Pro dir1  ../.ve/bin/py.test test_hello.py
=================================================== test session starts ====================================================
platform darwin -- Python 2.7.10 -- py-1.4.30 -- pytest-2.7.2 -- /Users/plauri/work/play/pytest-abs-rel-bug/.ve/bin/python2.7
rootdir: /Users/plauri/work/play/pytest-abs-rel-bug/dir1, inifile: pytest.ini
collected 1 items

test_hello.py::test_ok PASSED

================================================= 1 passed in 0.00 seconds =================================================
➜  plauri@Peters-MacBook-Pro dir1  ../.ve/bin/py.test test_hello.py /Users/plauri/work/play/pytest-abs-rel-bug/dir2
=================================================== test session starts ====================================================
platform darwin -- Python 2.7.10 -- py-1.4.30 -- pytest-2.7.2
rootdir: /Users/plauri/work/play/pytest-abs-rel-bug, inifile:
collected 2 items

test_hello.py .
../dir2/test_hola.py .

================================================= 2 passed in 0.01 seconds =================================================
➜  plauri@Peters-MacBook-Pro dir1  ../.ve/bin/py.test test_hello.py -s /Users/plauri/work/play/pytest-abs-rel-bug/dir2
=================================================== test session starts ====================================================
platform darwin -- Python 2.7.10 -- py-1.4.30 -- pytest-2.7.2 -- /Users/plauri/work/play/pytest-abs-rel-bug/.ve/bin/python2.7
rootdir: /Users/plauri/work/play/pytest-abs-rel-bug/dir1, inifile: pytest.ini
collected 2 items

test_hello.py::test_ok PASSED
::test_ok <- ../dir2/test_hola.py PASSED

================================================= 2 passed in 0.01 seconds =================================================
➜  plauri@Peters-MacBook-Pro dir1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions