Skip to content

tests: skip symlink tests when platform forbids symlink creation (#5389) - #5391

Closed
Vansh-Sharmaa wants to merge 1 commit into
psf:mainfrom
Vansh-Sharmaa:fix-symlink-tests-windows-privilege
Closed

Vansh-Sharmaa wants to merge 1 commit into
psf:mainfrom
Vansh-Sharmaa:fix-symlink-tests-windows-privilege

Conversation

@Vansh-Sharmaa

Copy link
Copy Markdown

Description

On Windows without elevated privileges or Developer Mode enabled, creating symlinks raises OSError: [WinError 1314] A required privilege is not held by the client.

test_broken_symlink previously guarded against this with a skip handler since #287, but three tests in TestFileCollection (test_get_sources_symlink_and_force_exclude, test_get_sources_with_stdin_symlink_outside_root, and test_get_sources_with_stdin_filename_and_force_exclude_and_symlink) called symlink_to directly without a guard.

This PR adds a symlink_or_skip helper in tests/test_black.py and uses it across all symlink creation sites so that the test suite gracefully skips on platforms/environments where symlink creation is not permitted.

Fixes #5389

Checklist - did you ...

  • Implement any code style changes under the --preview style, following the stability policy? (N/A - test fix only)
  • Add an entry in CHANGES.md if necessary? (N/A - internal test fix)
  • Add / update tests if necessary?
  • Add new / update outdated documentation? (N/A)

On Windows without elevated privileges or Developer Mode enabled, creating symlinks raises OSError: [WinError 1314]. test_broken_symlink guarded against this with a skip handler since psf#287, but three tests in TestFileCollection called symlink_to directly without a guard.

Add a symlink_or_skip helper and use it across all symlink creation sites so that the tests gracefully skip on platforms/environments where symlink creation is not permitted.

Fixes psf#5389
@cobaltt7

Copy link
Copy Markdown
Collaborator

Fixed by #5390. Please avoid creating PRs for issues already with open PRs without asking first.

@cobaltt7 cobaltt7 closed this Sep 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Three symlink tests fail on Windows without symlink privilege (regression of #287)

2 participants