Skip to content

Commit aba0494

Browse files
committed
Renamed refresh to setup and removed alias function & added unittest
Renamed to simplify and avoid issue with nose tests trying to use `setup` as a setup for testing. Unittest implements basic test for refreshing with a bad git path versus a good git path.
1 parent feed81e commit aba0494

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

git/__init__.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,16 @@ def _init_externals():
5858
__all__ = [name for name, obj in locals().items()
5959
if not (name.startswith('_') or inspect.ismodule(obj))]
6060

61+
6162
#{ Initialize git executable path
62-
def setup(path=None):
63+
def refresh(path=None):
6364
"""Convenience method for setting the git executable path."""
6465
if not Git.refresh(path=path):
6566
return
6667
if not FetchInfo.refresh():
6768
return
68-
69-
def refresh(path=None):
70-
"""Convenience method for refreshing the git executable path."""
71-
setup(path=path)
7269
#} END initialize git executable path
7370

7471
#################
75-
setup()
72+
refresh()
7673
#################

git/test/test_git.py

+9
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
from git import (
1212
Git,
13+
refresh,
1314
GitCommandError,
1415
GitCommandNotFound,
1516
Repo,
@@ -156,6 +157,14 @@ def test_cmd_override(self):
156157
type(self.git).GIT_PYTHON_GIT_EXECUTABLE = prev_cmd
157158
# END undo adjustment
158159

160+
def test_refresh(self):
161+
# test a bad git path refresh
162+
self.assertRaises(GitCommandNotFound, refresh, "yada")
163+
164+
# test a good path refresh
165+
path = os.popen("which git").read().strip()
166+
refresh(path)
167+
159168
def test_options_are_passed_to_git(self):
160169
# This work because any command after git --version is ignored
161170
git_version = self.git(version=True).NoOp()

0 commit comments

Comments
 (0)