Skip to content

Commit 5d0ad08

Browse files
committed
Improved windows test suite.
Also added code to show how to deal with #147
1 parent c824bcd commit 5d0ad08

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

git/test/test_base.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -118,5 +118,16 @@ def test_add_unicode(self, rw_repo):
118118
file_path = os.path.join(rw_repo.working_dir, filename)
119119
open(file_path, "wb").write(b'something')
120120

121-
rw_repo.git.add(rw_repo.working_dir)
121+
122+
if os.name == 'nt':
123+
# on windows, there is no way this works, see images on
124+
# https://github.com/gitpython-developers/GitPython/issues/147#issuecomment-68881897
125+
# Therefore, it must be added using the python implementation
126+
rw_repo.index.add([file_path])
127+
# However, when the test winds down, rmtree fails to delete this file, which is recognized
128+
# as ??? only.
129+
else:
130+
# on posix, we can just add unicode files without problems
131+
rw_repo.git.add(rw_repo.working_dir)
132+
# end
122133
rw_repo.index.commit('message')

git/test/test_git.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,16 @@ def test_version(self):
121121

122122
def test_cmd_override(self):
123123
prev_cmd = self.git.GIT_PYTHON_GIT_EXECUTABLE
124+
if os.name == 'nt':
125+
exc = GitCommandError
126+
else:
127+
exc = OSError
128+
# end handle windows case
124129
try:
125130
# set it to something that doens't exist, assure it raises
126131
type(self.git).GIT_PYTHON_GIT_EXECUTABLE = os.path.join(
127132
"some", "path", "which", "doesn't", "exist", "gitbinary")
128-
self.failUnlessRaises(OSError, self.git.version)
133+
self.failUnlessRaises(exc, self.git.version)
129134
finally:
130135
type(self.git).GIT_PYTHON_GIT_EXECUTABLE = prev_cmd
131136
# END undo adjustment

0 commit comments

Comments
 (0)