def test_refresh_from_bad_relative_git_path_env(self):
        """Bad relative path from environment is kept relative and reported, not set."""
        # Relative paths are not resolved when refresh() is called with no arguments, so
        # use a string that's very unlikely to be a command name found in a path lookup.
        relative_path = "yada-e47e70c6-acbf-40f8-ad65-13af93c2195b"
        expected_pattern = rf"\n[ \t]*cmdline: {re.escape(relative_path)}\Z"

        with _rollback_refresh() as old_git_executable:
            with mock.patch.dict(os.environ, {"GIT_PYTHON_GIT_EXECUTABLE": relative_path}):
                with self.assertRaisesRegex(GitCommandNotFound, expected_pattern):
                    refresh()
                self.assertEqual(self.git.GIT_PYTHON_GIT_EXECUTABLE, old_git_executable)
Bad relative path from environment is kept relative and reported, not set.
test/test_git.py