Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit663e04c

Browse files
author
Jesse Whitehouse
committed
Add one more test verifying that a configuring max_redirects doesn't
prevent stop_after_attempts_count from being honoured.Also clarifies the assertion for max_redirects limitations to makesure that those MaxRetryError exceptions are because of redirectsspecifically as opposed to exceeding some other limits (count, duration etc.)Signed-off-by: Jesse Whitehouse <jesse.whitehouse@databricks.com>
1 parent07257ba commit663e04c

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

‎tests/e2e/common/retry_test_mixins.py‎

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ def _base_retry_max_redirect_raises(self, max_redirects, expected_call_count):
353353
}
354354
)asconn:
355355
pass
356-
356+
assert"too many redirects"==str(cm.exception.reason)
357357
# Total call count should be 3 (original + 2 retries)
358358
assertmock_obj.return_value.getresponse.call_count==expected_call_count
359359

@@ -394,3 +394,26 @@ def test_retry_max_redirects_unset_doesnt_redirect_forever(self):
394394

395395
# Total call count should be 6 (original + _retry_stop_after_attempts_count)
396396
assertmock_obj.return_value.getresponse.call_count==6
397+
398+
deftest_retry_max_redirects_is_bounded_by_stop_after_attempts_count(self):
399+
# If I add another 503 or 302 here the test will fail with a MaxRetryError
400+
responses= [
401+
{"status":302,"headers": {},"redirect_location":"/foo.bar"},
402+
{"status":500,"headers": {},"redirect_location":None},
403+
]
404+
405+
additional_settings= {
406+
"_retry_max_redirects":1,
407+
"_retry_stop_after_attempts_count":2,
408+
}
409+
410+
withpytest.raises(RequestError)ascm:
411+
withmock_sequential_server_responses(responses):
412+
withself.connection(
413+
extra_params={**self._retry_policy,**additional_settings}
414+
):
415+
pass
416+
417+
# The error should be the result of the 500, not because of too many requests.
418+
assert"too many redirects"notinstr(cm.value.message)
419+
assert"Error during request to server"instr(cm.value.message)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp