MCPcopy
hub / github.com/urllib3/urllib3 / test_configurable_backoff_max

Method test_configurable_backoff_max

test/test_retry.py:160–182  ·  view source on GitHub ↗

Configurable backoff is computed correctly

(self)

Source from the content-addressed store, hash-verified

158 assert retry.get_backoff_time() == max_backoff
159
160 def test_configurable_backoff_max(self) -> None:
161 """Configurable backoff is computed correctly"""
162 max_backoff = 1
163
164 retry = Retry(total=100, backoff_factor=0.2, backoff_max=max_backoff)
165 assert retry.get_backoff_time() == 0 # First request
166
167 retry = retry.increment(method="GET")
168 assert retry.get_backoff_time() == 0 # First retry
169
170 retry = retry.increment(method="GET")
171 assert retry.backoff_factor == 0.2
172 assert retry.total == 98
173 assert retry.get_backoff_time() == 0.4 # Start backoff
174
175 retry = retry.increment(method="GET")
176 assert retry.get_backoff_time() == 0.8
177
178 retry = retry.increment(method="GET")
179 assert retry.get_backoff_time() == max_backoff
180
181 retry = retry.increment(method="GET")
182 assert retry.get_backoff_time() == max_backoff
183
184 def test_configurable_retry_after_max(self) -> None:
185 """Configurable retry after is computed correctly"""

Callers

nothing calls this directly

Calls 3

get_backoff_timeMethod · 0.95
incrementMethod · 0.95
RetryClass · 0.90

Tested by

no test coverage detected