From aa5076626ca9f2ff1279c6b8e67408be9d0fa690 Mon Sep 17 00:00:00 2001 From: sroet Date: Wed, 15 Sep 2021 11:55:17 +0200 Subject: Add a way to force status codes inside AutoInterrupt._terminate, and let tests use it --- test/test_remote.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'test') 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 -- cgit v1.2.1