|
6 | 6 |
|
7 | 7 | import random
|
8 | 8 | import tempfile
|
| 9 | +import pytest |
9 | 10 | from unittest import skipIf
|
10 | 11 |
|
11 | 12 | from git import (
|
@@ -401,12 +402,12 @@ def _assert_push_and_pull(self, remote, rw_repo, remote_repo):
|
401 | 402 | res = remote.push(all=True)
|
402 | 403 | self._do_test_push_result(res, remote)
|
403 | 404 |
|
404 |
| - remote.pull('master', timeout=10.0) |
| 405 | + remote.pull('master', kill_after_timeout=10.0) |
405 | 406 |
|
406 | 407 | # cleanup - delete created tags and branches as we are in an innerloop on
|
407 | 408 | # the same repository
|
408 | 409 | 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) |
410 | 411 |
|
411 | 412 | @skipIf(HIDE_WINDOWS_FREEZE_ERRORS, "FIXME: Freezes!")
|
412 | 413 | @with_rw_and_rw_remote_repo('0.1.6')
|
@@ -467,7 +468,8 @@ def test_base(self, rw_repo, remote_repo):
|
467 | 468 | # Only for remotes - local cases are the same or less complicated
|
468 | 469 | # as additional progress information will never be emitted
|
469 | 470 | 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) |
471 | 473 | ran_fetch_test = True
|
472 | 474 | # END fetch test
|
473 | 475 |
|
@@ -651,3 +653,15 @@ def test_push_error(self, repo):
|
651 | 653 | rem = repo.remote('origin')
|
652 | 654 | with self.assertRaisesRegex(GitCommandError, "src refspec __BAD_REF__ does not match any"):
|
653 | 655 | 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