Skip to content

Commit d10c242

Browse files
codexByron
authored andcommitted
test: handle symlinked Git directories in refresh checks
The macOS Python 3.8 and 3.14 CI jobs each passed 1,348 tests but failed `test_refresh_with_good_relative_git_path_arg`. Installing the supported Homebrew Git exposes `/opt/homebrew/opt/git/bin` on `PATH`; changing into that directory resolves it to the versioned Cellar directory. Compute the expected relative executable path from the current directory after changing into it. This preserves the documented `Git.refresh()` behavior and executable symlinks while removing the test's assumption that `shutil.which()` and `os.getcwd()` retain the same directory spelling. Validation: reproduced the failure using a symlinked directory on `PATH`. All 36 refresh tests pass with both ordinary and symlinked `PATH` values. Ruff lint, Ruff format, and `git diff --check` pass.
1 parent 9babb09 commit d10c242

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎test/test_git.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -797,9 +797,11 @@ def test_refresh_with_good_relative_git_path_arg(self):
797797
dirname, basename = osp.split(absolute_path)
798798

799799
with cwd(dirname):
800+
# getcwd may resolve directory symlinks, such as Homebrew's opt/git in PATH.
801+
expected_path = osp.join(os.getcwd(), basename)
800802
with _rollback_refresh():
801803
refresh(basename)
802-
self.assertEqual(self.git.GIT_PYTHON_GIT_EXECUTABLE, absolute_path)
804+
self.assertEqual(self.git.GIT_PYTHON_GIT_EXECUTABLE, expected_path)
803805

804806
def test_version_info_is_cached(self):
805807
fake_version_info = (123, 456, 789)

0 commit comments

Comments
 (0)