Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update tests and add a comment about different behaviour of 'push' vs…
… 'fetch'
  • Loading branch information
sroet committed Sep 13, 2021
commit 3a81850800018c1c0423423261ac79964d2d7192
2 changes: 2 additions & 0 deletions git/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,8 @@ def stdout_handler(line: str) -> None:
try:
proc.wait(stderr=stderr_text)
except Exception:
# This is different than fetch (which fails if there is any std_err
# even if there is an output)
if not output:
raise
elif stderr_text:
Expand Down
20 changes: 17 additions & 3 deletions test/test_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import random
import tempfile
import pytest
from unittest import skipIf

from git import (
Expand Down Expand Up @@ -401,12 +402,12 @@ def _assert_push_and_pull(self, remote, rw_repo, remote_repo):
res = remote.push(all=True)
self._do_test_push_result(res, remote)

remote.pull('master', timeout=10.0)
remote.pull('master', kill_after_timeout=10.0)

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

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

Expand Down Expand Up @@ -651,3 +653,15 @@ def test_push_error(self, repo):
rem = repo.remote('origin')
with self.assertRaisesRegex(GitCommandError, "src refspec __BAD_REF__ does not match any"):
rem.push('__BAD_REF__')


class TestTimeouts(TestBase):
@with_rw_repo('HEAD', bare=False)
def test_timeout_funcs(self, repo):
for function in ["pull", "fetch"]: #"can't get push to reliably timeout
f = getattr(repo.remotes.origin, function)
assert f is not None # Make sure these functions exist

with self.assertRaisesRegex(GitCommandError,
"kill_after_timeout=0.01 s"):
f(kill_after_timeout=0.01)