Skip to content

rootdir is not considered as expected #11186

@roeniss

Description

@roeniss

note

I made a repository to reproduce the bug: https://github.com/roeniss/pytest-bug-rootdir

issue

> tree 
.
├── settings
│   └── pytest.ini
└── test
    └── test_hello.py

> pytest -c settings/pytest.ini
=== test session starts === 
platform darwin -- Python 3.11.4, pytest-7.4.0, pluggy-1.2.0
rootdir: /Users/roeniss/tmp/pytest-error-reproduce/settings
configfile: pytest.ini
collected 1 item

settings/test/test_hello.py .                                                                                                                       [100%

=== 1 passed in 0.00s ===  

As we can see above, settings/test/test_hello.py doesn't exist. I came up with some idea:

  1. rootdir is just a string placeholder for readability. It is set as the configuration's directory by default and does not affect any actual test run. So this is the expected output.
  2. rootdir is something that is considered as source root or test root, meaning that this is a real bug. What should happen here is that no test has run because settings directory has no test.
  3. rootdir is worked but somehow it fallbacks to root path because there is no test in settings or any reason. Then it starts finding test and find it, run, but sadly the output shows wrong directory. So the log-side should be fixed.

I brought this bug here because I'm not sure what rootdir actually does. Is there any correct assumption on my thought?

versions

> pip list
Package    Version
---------- -------
iniconfig  2.0.0
packaging  23.1
pip        23.1.2
pluggy     1.2.0
pytest     7.4.0
setuptools 67.6.1

> pytest --version
pytest 7.4.0

> neofetch
                    'c.          roeniss@Roenissui-MacBookAir-2.local
                 ,xNMM.          ------------------------------------
               .OMMMMo           OS: macOS 13.2.1 22D68 arm64
               OMMM0,            Host: Mac14,2
     .;loddo:' loolloddol;.      Kernel: 22.3.0
   cKMMMMMMMMMMNWMMMMMMMMMM0:    Uptime: 5 days, 15 hours, 30 mins
 .KMMMMMMMMMMMMMMMMMMMMMMMWd.    Packages: 278 (brew)
 XMMMMMMMMMMMMMMMMMMMMMMMX.      Shell: zsh 5.8.1
;MMMMMMMMMMMMMMMMMMMMMMMM:       Resolution: 2048x1152
:MMMMMMMMMMMMMMMMMMMMMMMM:       DE: Aqua
.MMMMMMMMMMMMMMMMMMMMMMMMX.      WM: Rectangle
 kMMMMMMMMMMMMMMMMMMMMMMMMWd.    Terminal: iTerm2
 .XMMMMMMMMMMMMMMMMMMMMMMMMMMk   Terminal Font: JetBrainsMono-Regular 11
  .XMMMMMMMMMMMMMMMMMMMMMMMMK.   CPU: Apple M2
    kMMMMMMMMMMMMMMMMMMMMMMd     GPU: Apple M2
     ;KMMMMMMMWXXWMMMMMMMk.      Memory: 1487MiB / 8192MiB
       .cooc,.    .,coo:.



  • a detailed description of the bug or problem you are having
  • output of pip list from the virtual environment you are using
  • pytest and operating system versions
  • minimal example if possible

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: collectionrelated to the collection phasetype: bugproblem that needs to be addressed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions