Backoff is computed correctly
(self)
| 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">"" |
nothing calls this directly
no test coverage detected