diff options
author | sroet <sanderroet@hotmail.com> | 2021-09-15 11:55:17 +0200 |
---|---|---|
committer | Sebastian Thiel <sebastian.thiel@icloud.com> | 2021-09-18 09:26:28 +0800 |
commit | aa5076626ca9f2ff1279c6b8e67408be9d0fa690 (patch) | |
tree | ff103d77b0f1aa5a254726a7ff2abfdde0ed6e7f /test/test_remote.py | |
parent | 893ddabd312535bfd906822e42f0223c40655163 (diff) | |
download | gitpython-aa5076626ca9f2ff1279c6b8e67408be9d0fa690.tar.gz |
Add a way to force status codes inside AutoInterrupt._terminate, and let tests use it
Diffstat (limited to 'test/test_remote.py')
-rw-r--r-- | test/test_remote.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/test/test_remote.py b/test/test_remote.py index 4c1d02c8..088fdad5 100644 --- a/test/test_remote.py +++ b/test/test_remote.py @@ -658,10 +658,16 @@ class TestRemote(TestBase): class TestTimeouts(TestBase): @with_rw_repo('HEAD', bare=False) def test_timeout_funcs(self, repo): - for function in ["pull"]: # can't get fetch and push to reliably timeout + # Force error code to prevent a race condition if the python thread is + # slow + default = Git.AutoInterrupt._status_code_if_terminate + Git.AutoInterrupt._status_code_if_terminate = -15 + for function in ["pull", "fetch"]: # can't get push to timeout f = getattr(repo.remotes.origin, function) assert f is not None # Make sure these functions exist - _ = f() # Make sure the function runs + _ = f() # Make sure the function runs with pytest.raises(GitCommandError, - match="kill_after_timeout=0.001 s"): - f(kill_after_timeout=0.001) + match="kill_after_timeout=0 s"): + f(kill_after_timeout=0) + + Git.AutoInterrupt._status_code_if_terminate = default |