@@ -235,8 +235,6 @@ def dictfunc():
235235
236236def test_upload_retry (tmpdir , default_repo , capsys ):
237237 """Print retry messages when the upload response indicates a server error."""
238- default_repo .disable_progress_bar = True
239-
240238 default_repo .session = pretend .stub (
241239 post = lambda url , data , allow_redirects , headers : response_with (
242240 status_code = 500 , reason = "Internal server error"
@@ -254,35 +252,25 @@ def test_upload_retry(tmpdir, default_repo, capsys):
254252 metadata_dictionary = lambda : {"name" : "fake" },
255253 )
256254
255+ def assert_retries (output , total ):
256+ retries = [line for line in output .splitlines () if line .startswith ("Received" )]
257+ assert retries == [
258+ (
259+ 'Received "500: Internal server error" '
260+ f"Package upload appears to have failed. Retry { i } of { total } "
261+ )
262+ for i in range (1 , total + 1 )
263+ ]
264+
257265 # Upload with default max_redirects of 5
258266 default_repo .upload (package )
259267
260- msg = [
261- (
262- "Uploading fake.whl\n "
263- 'Received "500: Internal server error" '
264- f"Package upload appears to have failed. Retry { i } of 5"
265- )
266- for i in range (1 , 6 )
267- ]
268-
269- captured = capsys .readouterr ()
270- assert captured .out == "\n " .join (msg ) + "\n "
268+ assert_retries (capsys .readouterr ().out , 5 )
271269
272270 # Upload with custom max_redirects of 3
273271 default_repo .upload (package , 3 )
274272
275- msg = [
276- (
277- "Uploading fake.whl\n "
278- 'Received "500: Internal server error" '
279- f"Package upload appears to have failed. Retry { i } of 3"
280- )
281- for i in range (1 , 4 )
282- ]
283-
284- captured = capsys .readouterr ()
285- assert captured .out == "\n " .join (msg ) + "\n "
273+ assert_retries (capsys .readouterr ().out , 3 )
286274
287275
288276@pytest .mark .parametrize (
0 commit comments