Fix node IDs for files outside rootdir#14571
Open
marko1olo wants to merge 1 commit into
Open
Conversation
d9c266d to
2b00ef0
Compare
2b00ef0 to
3ea16ec
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #9703.
When
-c config/pytest.inimakesconfig/therootdir, 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 seetest/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 -qpython -m pytest testing/test_collection.py::TestCollectFS -qpython -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 -qpython -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 -qpython -m ruff check src/_pytest/nodes.py src/_pytest/config/__init__.py testing/test_collection.pypython -m ruff format --check src/_pytest/nodes.py src/_pytest/config/__init__.py testing/test_collection.pygit diff --check