Skip to content

Fix node IDs for files outside rootdir#14571

Closed
marko1olo wants to merge 1 commit into
pytest-dev:mainfrom
marko1olo:fix-config-rootdir-nodeids
Closed

Fix node IDs for files outside rootdir#14571
marko1olo wants to merge 1 commit into
pytest-dev:mainfrom
marko1olo:fix-config-rootdir-nodeids

Conversation

@marko1olo
Copy link
Copy Markdown

Fixes #9703.

When -c config/pytest.ini makes config/ the rootdir, explicitly requested test files outside that rootdir currently receive empty filesystem collector node IDs. That can collapse different files with the same test name into the same cache key, for example ::test_same, and makes file-scoped fixture visibility depend on a broken parent node ID.

This changes outside-root filesystem collectors to use a stable path relative to rootdir, such as ../test/test_file1.py, instead of an empty node ID. Terminal display still renders paths relative to the invocation directory, so users see test/test_file1.py::... in output.

Checks run locally:

  • python -m pytest testing/test_collection.py::TestCollectFS::test_config_outside_test_paths_keeps_unique_lastfailed_nodeids testing/test_collection.py::TestCollectFS::test_config_outside_test_paths_keeps_file_scoped_autouse -q
  • python -m pytest testing/test_collection.py::TestCollectFS -q
  • python -m pytest testing/test_conftest.py::test_conftest_fixture_scoping_with_testpaths_outside_rootdir testing/test_conftest.py::test_conftest_fixture_from_ancestor_above_rootdir -q
  • python -m pytest testing/test_cacheprovider.py::TestLastFailed::test_lastfailed_usecase testing/test_cacheprovider.py::TestLastFailed::test_lastfailed_difference_invocations testing/test_cacheprovider.py::TestLastFailed::test_lastfailed_args_with_deselected testing/test_cacheprovider.py::TestLastFailed::test_lastfailed_collectfailure testing/test_cacheprovider.py::TestLastFailed::test_lastfailed_with_known_failures_not_being_selected -q
  • python -m ruff check src/_pytest/nodes.py src/_pytest/config/__init__.py testing/test_collection.py
  • python -m ruff format --check src/_pytest/nodes.py src/_pytest/config/__init__.py testing/test_collection.py
  • git diff --check

@psf-chronographer psf-chronographer Bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Jun 7, 2026
@marko1olo marko1olo force-pushed the fix-config-rootdir-nodeids branch 2 times, most recently from d9c266d to 2b00ef0 Compare June 7, 2026 00:41
@marko1olo marko1olo force-pushed the fix-config-rootdir-nodeids branch from 2b00ef0 to 3ea16ec Compare June 7, 2026 00:50
@RonnyPfannschmidt
Copy link
Copy Markdown
Member

closing this as unattended ai change - the changes done here are unacceptable as they dont change the origon of the problem but mess around with other stuff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided (automation) changelog entry is part of PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Scopes of several files are merged when specifying a config using -c

2 participants