Skip to content

Commit 7bbaac2

Browse files
committed
test, #519: Popen() universal_newlin.es NoWindow in Winfoes
+ More win-fixes: + Do not check unicode files in < py3. + util, #519: x4 timeout of lock-file blocking, failing in Appveyor.
1 parent fa70623 commit 7bbaac2

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

‎git/index/fun.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@
1212

1313
from io import BytesIO
1414
import os
15+
import sys
1516
import subprocess
1617

1718
from git.util import IndexFileSHA1Writer
19+
from git.cmd import Git
1820
from git.exc import (
1921
UnmergedEntriesError,
2022
HookExecutionError
@@ -74,7 +76,9 @@ def run_commit_hook(name, index):
7476
stdout=subprocess.PIPE,
7577
stderr=subprocess.PIPE,
7678
cwd=index.repo.working_dir,
77-
close_fds=(os.name == 'posix'))
79+
close_fds=(os.name == 'posix'),
80+
universal_newlines=True,
81+
creationflags=Git.CREATE_NO_WINDOW if sys.platform == 'win32' else 0,)
7882
stdout, stderr = cmd.communicate()
7983
cmd.stdout.close()
8084
cmd.stderr.close()

‎git/test/test_base.py

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import os
88
import sys
99
import tempfile
10+
from unittest import skipIf
1011

1112
import git.objects.base as base
1213
from git.test.lib import (
@@ -116,6 +117,8 @@ def test_with_rw_remote_and_rw_repo(self, rw_repo, rw_remote_repo):
116117
assert rw_remote_repo.config_reader("repository").getboolean("core", "bare")
117118
assert os.path.isdir(os.path.join(rw_repo.working_tree_dir, 'lib'))
118119

120+
@skipIf(sys.version_info < (3, ) and os.name == 'nt',
121+
"Unicode woes, see https://github.com/gitpython-developers/GitPython/pull/519")
119122
@with_rw_repo('0.1.6')
120123
def test_add_unicode(self, rw_repo):
121124
filename = u"שלום.txt"

‎git/test/test_git.py

+2
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,8 @@ def counter_stderr(line):
239239
stdout=subprocess.PIPE,
240240
stderr=subprocess.PIPE,
241241
shell=False,
242+
universal_newlines=True,
243+
creationflags=Git.CREATE_NO_WINDOW if sys.platform == 'win32' else 0,
242244
)
243245

244246
handle_process_output(proc, counter_stdout, counter_stderr, lambda proc: proc.wait())

‎git/test/test_util.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from git.compat import string_types
2828

2929
import time
30+
import sys
3031

3132

3233
class TestIterableMember(object):
@@ -90,7 +91,11 @@ def test_blocking_lock_file(self):
9091
wait_lock = BlockingLockFile(my_file, 0.05, wait_time)
9192
self.failUnlessRaises(IOError, wait_lock._obtain_lock)
9293
elapsed = time.time() - start
93-
assert elapsed <= wait_time + 0.02, elapsed # some extra time it may cost
94+
# More extra time costs, but...
95+
extra_time = 0.2
96+
if sys.platform == 'win32':
97+
extra_time *= 4
98+
self.assertLess(elapsed, wait_time + 0.02)
9499

95100
def test_user_id(self):
96101
assert '@' in get_user_id()

0 commit comments

Comments
 (0)