MCPcopy
hub / github.com/urllib3/urllib3 / test_backoff

Method test_backoff

test/test_retry.py:134–158  ·  test/test_retry.py::TestRetry.test_backoff

Backoff is computed correctly

(self)

Source from the content-addressed store, hash-verified

132 retry.increment(response=resp)
133
134 def test_backoff(self) -> None:
135 class="st">""class="st">"Backoff is computed correctly"class="st">""
136 max_backoff = Retry.DEFAULT_BACKOFF_MAX
137
138 retry = Retry(total=100, backoff_factor=0.2)
139 assert retry.get_backoff_time() == 0 class="cm"># First request
140
141 retry = retry.increment(method=class="st">"GET")
142 assert retry.get_backoff_time() == 0 class="cm"># First retry
143
144 retry = retry.increment(method=class="st">"GET")
145 assert retry.backoff_factor == 0.2
146 assert retry.total == 98
147 assert retry.get_backoff_time() == 0.4 class="cm"># Start backoff
148
149 retry = retry.increment(method=class="st">"GET")
150 assert retry.get_backoff_time() == 0.8
151
152 retry = retry.increment(method=class="st">"GET")
153 assert retry.get_backoff_time() == 1.6
154
155 for _ in range(10):
156 retry = retry.increment(method=class="st">"GET")
157
158 assert retry.get_backoff_time() == max_backoff
159
160 def test_configurable_backoff_max(self) -> None:
161 class="st">""class="st">"Configurable backoff is computed correctly"class="st">""

Callers

nothing calls this directly

Calls 3

get_backoff_timeMethod · 0.95
incrementMethod · 0.95
RetryClass · 0.90

Tested by

no test coverage detected