-
Is it expected behavior for the nodeid of items collected from python files located outside the rootdir to look like import tempfile
import textwrap
from pathlib import Path
import pytest
@pytest.fixture()
def test_file_outside_rootdir():
with tempfile.TemporaryDirectory() as tmp_path:
root_dir = Path(tmp_path)
testdir = root_dir.joinpath("sub-directory")
testdir.mkdir(parents=True, exist_ok=False)
filename = testdir.joinpath("test_foo.py")
data = textwrap.dedent(
"""
import pytest
@pytest.mark.parametrize("x", [1, 2, 3])
def test_parametrized_function_outside_rootdir(request: pytest.FixtureRequest, x: int):
assert not request.node.nodeid.startswith("::")
def test_function_outside_rootdir(request: pytest.FixtureRequest):
assert not request.node.nodeid.startswith("::")
class TestFoo:
def test_class_method_outside_rootdir(self, request: pytest.FixtureRequest):
assert not request.node.nodeid.startswith("::")
"""
)
filename.write_text(data, encoding="utf-8")
yield filename
def test_pycollect_test_function_outside_rootdir(pytester: pytest.Pytester, test_file_outside_rootdir: Path):
pytester.makefile(".ini", pytest=f"[pytest]\naddopts =\n")
result = pytester.runpytest(str(test_file_outside_rootdir), "--rootdir", pytester.path, "-vv", "-s")
result.assert_outcomes(failed=0, passed=5)
assert result.ret == pytest.ExitCode.OK The currently observed behavior seems to be the outcome of the function |
Beta Was this translation helpful? Give feedback.
Answered by
bluetech
Aug 16, 2023
Replies: 1 comment 1 reply
-
I've recently opened an issue about this: #11245 |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
spadman1
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've recently opened an issue about this: #11245