Repository navigation
Skip symlink tests when the platform forbids creating one - #5390
Merged
Merged
Conversation
Three tests in TestFileCollection create symlinks without a guard, so they fail with WinError 1314 for any Windows contributor who is not elevated and does not have Developer Mode enabled. The guard pattern already exists since GH psf#287 (test_broken_symlink), but the three tests added later never picked it up. CI cannot catch this because the Windows runner can create symlinks. Add a shared symlink_or_skip helper (pytest.skip, as TestFileCollection is a plain pytest class) and use it at all five symlink_to call sites, so the next symlink test picks up the guard by default. On Windows: 3 failed / 442 passed -> 0 failed / 442 passed, with the three tests reporting a clear skip reason.
Contributor
Author
|
Test-only change — no user-facing behavior is touched, so there's nothing to report in CHANGES.md. Could a maintainer add the |
Collaborator
|
Thanks! |
4 tasks done
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 #5389.
What
Three tests in
TestFileCollectioncreate symlinks without any guard, so the test suite fails withOSError: [WinError 1314]for any Windows contributor who is neither elevated nor running with Developer Mode enabled:test_get_sources_symlink_and_force_excludetest_get_sources_with_stdin_symlink_outside_roottest_get_sources_with_stdin_filename_and_force_exclude_and_symlinkThis is the same problem #287 fixed in 2018 for
test_broken_symlink— that guard is still in place and working, but the three tests above were added later without it. CI cannot catch the regression because the Windows runner can create symlinks; only an ordinary local Windows checkout fails.Change
Add a module-level
symlink_or_skip(link, target)helper next to the other test utilities and use it at all fivesymlink_tocall sites inTestFileCollection:Notes:
pytest.skipinstead ofself.skipTest, sinceTestFileCollectionis a plain pytest class, not aunittest.TestCase(test_broken_symlinkkeeps its existingskipTestguard).Verification
3 failed, 442 passedon Windows (WinError 1314) — matches the issue report.0 failed / 442 passed, with the three tests reportingSKIPPED (Can't create symlinks: ...).442 passed, 7 skipped, 8 subtests passed(pytest --ignore=tests/test_blackd.py).black --check tests/test_black.py,flake8,isort --check-only, andmypyall pass.Changelog
Test-only change with no user-facing behaviour impact, so I believe no
CHANGES.mdentry is needed — happy to add one under the appropriate heading if you prefer.