-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Scopes of several files are merged when specifying a config using -c
#9703
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
Comments
at first glance this is a issue with node id computation messing up with relative pathnames, |
I think the problem here is both node ids are: ::test_in_file1
::test_in_file2 when test/test_file1.py::test_in_file1
test/test_file2.py::test_in_file2 as nodeids respectfully here, heres a test that passes due to the breakage if anyone beats me to it! def test_passing_config_works_correctly(pytester: pytest.Pytester) -> None:
"""Regression for #9703"""
test_sub = pytester.mkdir("test")
test_sub.joinpath("test_file1.py").write_text(
textwrap.dedent(
"""
import pytest
@pytest.fixture(autouse=True)
def some_fixture():
print("Fixture called")
def test_in_file1():
print("test_in_file1")
"""
)
)
test_sub.joinpath("test_file2.py").write_text(
textwrap.dedent(
"""
import pytest
def test_in_file2():
print("test_in_file2")
"""
)
)
config_sub = pytester.mkdir("config")
config_sub.joinpath("pytest.ini").write_text(
textwrap.dedent(
"""
[pytest]
"""
)
)
output = pytester.runpytest(
"-c",
"config/pytest.ini",
"-s",
"-v",
"test/test_file1.py",
"test/test_file2.py",
)
output.stdout.fnmatch_lines("test/test_file1.py::test_in_file1 Fixture called")
output.stdout.fnmatch_lines("test/test_file2.py::test_in_file2 test_in_file2") Think this largely stems from essentially the same as running |
Why does specifying a config file set the rootdir? Shouldn't it be independent? |
I don't know enough about the internals to answer that but I'm happy to look further into it when I wrap up some other things, hopefully someone in the know can give us some reasoning on that |
Uh oh!
There was an error while loading. Please reload this page.
Setup:
Python 3.9.9,
pip list
:(basically just whatever
pip install pytest
installs)Files:
Running with specifying the config from
config
explicitly executes the fixture for both tests:py.test -c config/pytest.ini -s -v tests/test_file1.py tests/test_file2.py
Omitting the config, using a config from the root directory
<dir>
, or not specifying the test files explicitly (justpy.test -c config/pytest.ini -s -v
):which is the behavior I would expect.
Downgrading to
pytest==6.2.5
and running the command above (py.test -c config/pytest.ini -s -v tests/test_file1.py tests/test_file2.py
) does not lead to the bug either. Interestingly enough, the "config" prefix is missing from the output:Must be some config-based grouping feature introduced in 7?
The text was updated successfully, but these errors were encountered: