Skip to content
Prev Previous commit
Next Next commit
Merge branch 'main' into 818-rich-progress
  • Loading branch information
bhrutledge committed Mar 11, 2022
commit fbe8e1119f83d47f1c6548ec88a9e4259eeef25c
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ install_requires=
requests >= 2.20
requests-toolbelt >= 0.8.0, != 0.9.0
urllib3 >= 1.26.0
importlib_metadata >= 3.6
importlib-metadata >= 3.6
keyring >= 15.1
rfc3986 >= 1.4.0
rich >= 12.0.0
Expand Down
28 changes: 16 additions & 12 deletions tests/test_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,25 +244,29 @@ def test_upload_retry(tmpdir, default_repo, caplog):
metadata_dictionary=lambda: {"name": "fake"},
)

def assert_retries(output, total):
retries = [line for line in output.splitlines() if line.startswith("Received")]
assert retries == [
(
'Received "500: Internal server error" '
f"Package upload appears to have failed. Retry {i} of {total}"
)
for i in range(1, total + 1)
]

# Upload with default max_redirects of 5
default_repo.upload(package)

assert_retries(capsys.readouterr().out, 5)
assert caplog.messages == [
(
'Received "500: Internal server error"\n'
f"Package upload appears to have failed. Retry {i} of 5."
)
for i in range(1, 6)
]

caplog.clear()

# Upload with custom max_redirects of 3
default_repo.upload(package, 3)

assert_retries(capsys.readouterr().out, 3)
assert caplog.messages == [
(
'Received "500: Internal server error"\n'
f"Package upload appears to have failed. Retry {i} of 3."
)
for i in range(1, 4)
]


@pytest.mark.parametrize(
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.