Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testpaths is ignored when specifying the config file with -c #9723

Open
pacahon opened this issue Mar 1, 2022 · 2 comments
Open

testpaths is ignored when specifying the config file with -c #9723

pacahon opened this issue Mar 1, 2022 · 2 comments
Labels
topic: config related to config handling, argument parsing and config file

Comments

@pacahon
Copy link

pacahon commented Mar 1, 2022

$ pip list
Package    Version
---------- -----------------------
attrs      21.4.0
iniconfig  1.1.1
packaging  21.3
pip        21.1.3
pluggy     1.0.0
py         1.11.0
pyparsing  3.0.7
pytest     7.1.0.dev236+ge466a87bb
setuptools 56.0.0
tomli      2.0.1

Minimal example

# <dir>/pytest.ini
[pytest]
testpaths = tests1
# <dir>/tests1/test_1.py
def test_1():
    assert True
# <dir>/dir1/pytest.ini
[pytest]
testpaths = tests2
# <dir>/dir1/tests2/test_2.py
def test_2():
    assert False

Steps to reproduce

Run pytest commands from the <dir>

$  pytest --collect-only

platform darwin -- Python 3.9.6, pytest-7.1.0.dev236+ge466a87bb, pluggy-1.0.0
rootdir: /Users/pacahon/Downloads/tmp/pytest, configfile: pytest.ini, testpaths: tests1
collected 1 item

<Module tests1/test_1.py>
  <Function test_1>

$ pytest -c dir1/pytest.ini --collect-only

platform darwin -- Python 3.9.6, pytest-7.1.0.dev236+ge466a87bb, pluggy-1.0.0
rootdir: /Users/pacahon/Downloads/tmp/pytest/dir1, configfile: pytest.ini
collected 2 items

<Module tests2/test_2.py>
  <Function test_2>
<Module test_1.py>
  <Function test_1>

Expected behavior

1 collected item while executing the second command + testpaths info in the output headers (since dir1 is the rootdir). Something like this:

$ pytest -c dir1/pytest.ini --collect-only

platform darwin -- Python 3.9.6, pytest-7.1.0.dev236+ge466a87bb, pluggy-1.0.0
rootdir: /Users/pacahon/Downloads/tmp/pytest/dir1, configfile: pytest.ini, testpaths: tests2
collected 1 item

<Module tests2/test_2.py>
  <Function test_2>

P.S: I experience the same behaviour with 7.0.1 from pypi. 6.2.5 gives me an error ERROR: file or directory not found: tests2
P.P.S. Maybe related to #9703

@Zac-HD Zac-HD added the topic: config related to config handling, argument parsing and config file label Mar 5, 2022
@elbehery95
Copy link
Contributor

I recall in #8846 it was mentioned that all the cli args must be passed in this form -c=dir1/pytest.ini and not in this form -c dir1/pytest.ini.

@pacahon
Copy link
Author

pacahon commented Mar 9, 2022

As I understand this applies to the unknown options only. Anyway, I tried both versions and they work the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: config related to config handling, argument parsing and config file
Projects
None yet
Development

No branches or pull requests

3 participants