Skip to content

Commit 42d8069

Browse files
committed
Add unittest for blocking api
1 parent 435565a commit 42d8069

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

tests/test_retry.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ def _do(self):
9595
def _fail(self, error):
9696
self.actual_failures += 1
9797

98+
def _fail_inf(self, error):
99+
self.actual_failures += 1
100+
if self.actual_failures == 5:
101+
raise ConnectionError()
102+
98103
@pytest.mark.parametrize("retries", range(10))
99104
def test_retry(self, retries):
100105
backoff = BackoffMock()
@@ -107,6 +112,16 @@ def test_retry(self, retries):
107112
assert backoff.reset_calls == 1
108113
assert backoff.calls == retries
109114

115+
def test_infinite_retry(self):
116+
backoff = BackoffMock()
117+
# specify infinite retries, but give up after 5
118+
retry = Retry(backoff, -1)
119+
with pytest.raises(ConnectionError):
120+
retry.call_with_retry(self._do, self._fail_inf)
121+
122+
assert self.actual_attempts == 5
123+
assert self.actual_failures == 5
124+
110125

111126
@pytest.mark.onlynoncluster
112127
class TestRedisClientRetry:

0 commit comments

Comments
 (0)