@@ -34,8 +34,11 @@ def test_sleep__no_retry_after(self, t_mock, retry_policy, error_history):
3434 retry_policy .history = [error_history , error_history ]
3535 retry_policy .sleep (HTTPResponse (status = 503 ))
3636
37- expected_backoff_time = self .calculate_backoff_time (
38- 0 , retry_policy .delay_min , retry_policy .delay_max
37+ expected_backoff_time = max (
38+ self .calculate_backoff_time (
39+ 0 , retry_policy .delay_min , retry_policy .delay_max
40+ ),
41+ retry_policy .delay_max ,
3942 )
4043 t_mock .assert_called_with (expected_backoff_time )
4144
@@ -54,8 +57,11 @@ def test_sleep__no_retry_after_header__multiple_retries(self, t_mock, retry_poli
5457 expected_backoff_times = []
5558 for attempt in range (num_attempts ):
5659 expected_backoff_times .append (
57- self .calculate_backoff_time (
58- attempt , retry_policy .delay_min , retry_policy .delay_max
60+ max (
61+ self .calculate_backoff_time (
62+ attempt , retry_policy .delay_min , retry_policy .delay_max
63+ ),
64+ retry_policy .delay_max ,
5965 )
6066 )
6167
@@ -77,10 +83,3 @@ def test_excessive_retry_attempts_error(self, t_mock, retry_policy):
7783 retry_policy .sleep (HTTPResponse (status = 503 ))
7884 # Internally urllib3 calls the increment function generating a new instance for every retry
7985 retry_policy = retry_policy .increment ()
80-
81- @patch ("time.sleep" )
82- def test_sleep__retry_after_present (self , t_mock , retry_policy , error_history ):
83- retry_policy ._retry_start_time = time .time ()
84- retry_policy .history = [error_history , error_history , error_history ]
85- retry_policy .sleep (HTTPResponse (status = 503 , headers = {"Retry-After" : "3" }))
86- t_mock .assert_called_with (3 )
0 commit comments