In test_git.py, TestGit.test_refresh tests the behavior of git.refresh when called with bad (nonexistent) and good (existing and usable) explicit path arguments.
- With the bad path, there could only be a lasting change to
Git.GIT_PYTHON_GIT_EXECUTABLE or other global state due to a bug in git.refresh, or in git.cmd.Git.refresh or some other code git.refresh uses.
- But with the good path, it remains set as
Git.GIT_PYTHON_GIT_EXECUTABLE, and tests that run after test_refresh use that instead of the original value that (when tests are run normally in an environment that supports them) is usually "git".
|
def test_refresh(self): |
|
# Test a bad git path refresh. |
|
self.assertRaises(GitCommandNotFound, refresh, "yada") |
|
|
|
# Test a good path refresh. |
|
which_cmd = "where" if os.name == "nt" else "command -v" |
|
path = os.popen("{0} git".format(which_cmd)).read().strip().split("\n")[0] |
|
refresh(path) |
>>> from git import Git
>>> from test.test_git import TestGit
>>> t = TestGit()
>>> Git.GIT_PYTHON_GIT_EXECUTABLE
'git'
>>> t.test_refresh()
>>> Git.GIT_PYTHON_GIT_EXECUTABLE
'C:\\Users\\ek\\scoop\\shims\\git.exe'
(That was run on Windows, but the effect is not specific to Windows.)
Although the good-path code can be simplified in the way it finds the absolute path it tests, that is not the cause of this.
In the absence of bugs in the code under test, this change to Git.GIT_PYTHON_GIT_EXECUTABLE between some tests and others should make no difference on most working test systems, because both the old and new paths should both work and typically run the same git installation. However, if there are bugs related to this attribute that the test suite should reveal or that otherwise interact with tests, then I think this may lead to inaccurate or less useful results, or complicate troubleshooting.
In
test_git.py,TestGit.test_refreshtests the behavior ofgit.refreshwhen called with bad (nonexistent) and good (existing and usable) explicitpatharguments.Git.GIT_PYTHON_GIT_EXECUTABLEor other global state due to a bug ingit.refresh, or ingit.cmd.Git.refreshor some other codegit.refreshuses.Git.GIT_PYTHON_GIT_EXECUTABLE, and tests that run aftertest_refreshuse that instead of the original value that (when tests are run normally in an environment that supports them) is usually"git".GitPython/test/test_git.py
Lines 309 to 316 in 307f198
(That was run on Windows, but the effect is not specific to Windows.)
Although the good-path code can be simplified in the way it finds the absolute path it tests, that is not the cause of this.
In the absence of bugs in the code under test, this change to
Git.GIT_PYTHON_GIT_EXECUTABLEbetween some tests and others should make no difference on most working test systems, because both the old and new paths should both work and typically run the samegitinstallation. However, if there are bugs related to this attribute that the test suite should reveal or that otherwise interact with tests, then I think this may lead to inaccurate or less useful results, or complicate troubleshooting.