Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.

Commit 035dab1

Browse files
committed
added backoff generator test
1 parent 1986b06 commit 035dab1

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

tests/unit/data/test__helpers.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,22 @@ def test_attempt_timeout_w_sleeps(self):
9999
expected_value -= sleep_time
100100

101101

102+
class TestBackoffGenerator:
103+
104+
def test_backoff_generator_history(self):
105+
"""
106+
Should be able to retrieve historical results from backoff generator
107+
"""
108+
generator = _helpers.BackoffGenerator(initial=0, multiplier=2, maximum=10)
109+
got_list = [next(generator) for _ in range(20)]
110+
111+
# check all values are correct
112+
for i in range(19, 0, -1):
113+
assert generator.get_attempt_backoff(i) == got_list[i]
114+
# check a random value out of order
115+
assert generator.get_attempt_backoff(5) == got_list[5]
116+
117+
102118
class TestValidateTimeouts:
103119
def test_validate_timeouts_error_messages(self):
104120
with pytest.raises(ValueError) as e:

0 commit comments

Comments
 (0)