Skip to content

Commit 0a58afe

Browse files
sroetByron
authored andcommitted
update tests and add a comment about different behaviour of 'push' vs 'fetch'
1 parent ef0ca65 commit 0a58afe

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

git/remote.py

+2
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,8 @@ def stdout_handler(line: str) -> None:
795795
try:
796796
proc.wait(stderr=stderr_text)
797797
except Exception:
798+
# This is different than fetch (which fails if there is any std_err
799+
# even if there is an output)
798800
if not output:
799801
raise
800802
elif stderr_text:

test/test_remote.py

+17-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import random
88
import tempfile
9+
import pytest
910
from unittest import skipIf
1011

1112
from git import (
@@ -401,12 +402,12 @@ def _assert_push_and_pull(self, remote, rw_repo, remote_repo):
401402
res = remote.push(all=True)
402403
self._do_test_push_result(res, remote)
403404

404-
remote.pull('master', timeout=10.0)
405+
remote.pull('master', kill_after_timeout=10.0)
405406

406407
# cleanup - delete created tags and branches as we are in an innerloop on
407408
# the same repository
408409
TagReference.delete(rw_repo, new_tag, other_tag)
409-
remote.push(":%s" % other_tag.path, timeout=10.0)
410+
remote.push(":%s" % other_tag.path, kill_after_timeout=10.0)
410411

411412
@skipIf(HIDE_WINDOWS_FREEZE_ERRORS, "FIXME: Freezes!")
412413
@with_rw_and_rw_remote_repo('0.1.6')
@@ -467,7 +468,8 @@ def test_base(self, rw_repo, remote_repo):
467468
# Only for remotes - local cases are the same or less complicated
468469
# as additional progress information will never be emitted
469470
if remote.name == "daemon_origin":
470-
self._do_test_fetch(remote, rw_repo, remote_repo, timeout=10.0)
471+
self._do_test_fetch(remote, rw_repo, remote_repo,
472+
kill_after_timeout=10.0)
471473
ran_fetch_test = True
472474
# END fetch test
473475

@@ -651,3 +653,15 @@ def test_push_error(self, repo):
651653
rem = repo.remote('origin')
652654
with self.assertRaisesRegex(GitCommandError, "src refspec __BAD_REF__ does not match any"):
653655
rem.push('__BAD_REF__')
656+
657+
658+
class TestTimeouts(TestBase):
659+
@with_rw_repo('HEAD', bare=False)
660+
def test_timeout_funcs(self, repo):
661+
for function in ["pull", "fetch"]: #"can't get push to reliably timeout
662+
f = getattr(repo.remotes.origin, function)
663+
assert f is not None # Make sure these functions exist
664+
665+
with self.assertRaisesRegex(GitCommandError,
666+
"kill_after_timeout=0.01 s"):
667+
f(kill_after_timeout=0.01)

0 commit comments

Comments
 (0)