fix(tests): skip symlink test gracefully when creation is unavailable on Windows#653
Open
iamadhitya1 wants to merge 1 commit into
Open
fix(tests): skip symlink test gracefully when creation is unavailable on Windows#653iamadhitya1 wants to merge 1 commit into
iamadhitya1 wants to merge 1 commit into
Conversation
… on Windows On Windows, Path.symlink_to() raises OSError (WinError 1314) for standard users without Developer Mode enabled. Wrapping the symlink call in a try/except and calling pytest.skip() lets the test run when symlinks are available (Developer Mode) while skipping cleanly when they are not, instead of crashing the test suite. Fixes usestrix#650
Contributor
Greptile SummaryThis PR makes the symlink size test skip cleanly when symlink creation is unavailable. The main changes are:
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (1): Last reviewed commit: "fix(tests): skip symlink test gracefully..." | Re-trigger Greptile |
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.
Problem
test_directory_size_skips_symlinksintests/test_local_sources.pycrashes on Windows for standard users (non-Administrator, Developer Mode off) becausePath.symlink_to()raisesOSError: [WinError 1314] A required privilege is not held by the client.Fixes #650
Fix
Wrap the symlink creation in a
try/except OSErrorand callpytest.skip()if it fails. This is better than a blanketskipif(sys.platform == "win32")because the test still runs on Windows when symlinks are available (Developer Mode enabled or running as Administrator), and skips cleanly only when they are not.Changes
tests/test_local_sources.py: 5-line change — wrapsymlink_to()in try/except, skip with an explanatory message on failure.Before / After
Before: test crashes with
OSError: [WinError 1314]on Windows standard users, blocking the entire test suite.After: test skips with
"symlink creation unavailable; on Windows run as Administrator or enable Developer Mode"and the suite continues.