Skip to content

Skip tests that need symlink privileges instead of erroring - #2197

Merged
Byron merged 3 commits into
gitpython-developers:mainfrom
Cyrus580529:shared-symlink-guard
Aug 4, 2026
Merged

Skip tests that need symlink privileges instead of erroring#2197
Byron merged 3 commits into
gitpython-developers:mainfrom
Cyrus580529:shared-symlink-guard

Conversation

@Cyrus580529

Copy link
Copy Markdown
Contributor

Summary

  • Move the symlink capability probe out of test/test_index.py into test/lib/helper.py as symlinks_supported(), and add a requires_symlinks skip marker beside it.
  • Apply the marker to the three tests that call os.symlink unguarded and error with OSError: [WinError 1314] on a Windows account without Developer Mode or SeCreateSymbolicLinkPrivilege.
  • Drop the two existing copies of the check: the private probe in test_index.py, and the inline try/except plus skipTest in test_refs.py.

The tests that were erroring:

  • test_repo.py::TestRepo::test_ignored_raises_error_w_symlink
  • test_util.py::TestRmtree::test_avoids_changing_permissions_outside_tree
  • test_installation.py::TestInstallation::test_installation

CI doesn't show this because the GitHub Windows runners hold the privilege, so the three run and pass there.

One behaviour note: the probe used to return early on non-Windows, so it never created anything. Now it always creates and removes a symlink in a temporary directory, on every platform.

Validation

Windows 11, Python 3.13, after ./init-tests-after-clone.sh:

  • python -m pytest --ignore=test/performance — before: 6 failed, 711 passed, 47 skipped. After: 3 failed, 711 passed, 50 skipped.
  • The three remaining failures are unrelated to symlinks: test_commit_msg_hook_fail, test_pre_commit_hook_fail, and test_index_mutation, which passes a POSIX absolute path to git rm.
  • python -m ruff check test/
  • python -m ruff format --check test/
Whether a symlink can be created isn't decided by the platform alone: on
Windows it needs Developer Mode or SeCreateSymbolicLinkPrivilege.
These called os.symlink unguarded, so on a Windows account without the
privilege they errored with WinError 1314 instead of being skipped.
test_index had a private probe and test_refs repeated the same check
inline.
@Byron
Byron force-pushed the shared-symlink-guard branch from 57a2232 to b10e250 Compare August 4, 2026 14:28
@Byron
Byron merged commit fc2f02c into gitpython-developers:main Aug 4, 2026
53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants