Skip to content

Commit

Permalink
Tweak upload --verbose suggestion (#817)
Browse files Browse the repository at this point in the history
* Tweak upload --verbose suggestion

* Create 817.bugfix.rst
  • Loading branch information
bhrutledge committed Oct 8, 2021
1 parent 28d8571 commit 040a62c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
1 change: 1 addition & 0 deletions changelog/817.bugfix.rst
@@ -0,0 +1 @@
Generalize ``--verbose`` suggestion when an upload fails.
7 changes: 1 addition & 6 deletions tests/test_utils.py
Expand Up @@ -285,12 +285,7 @@ def test_check_status_code_for_missing_status_code(
if verbose:
assert captured.out.count("Content received from server:\nForbidden\n") == 1
else:
assert (
captured.out.count(
"For more details, retry the upload with the --verbose option.\n"
)
== 1
)
assert captured.out.count("--verbose option") == 1


@pytest.mark.parametrize(
Expand Down
11 changes: 7 additions & 4 deletions twine/utils.py
Expand Up @@ -197,12 +197,15 @@ def check_status_code(response: requests.Response, verbose: bool) -> None:
try:
response.raise_for_status()
except requests.HTTPError as err:
if not verbose:
logger.warning(
"Error during upload. "
"Retry with the --verbose option for more details."
)

if response.text:
logger.info("Content received from server:\n{}".format(response.text))
if not verbose:
logger.warning(
"For more details, retry the upload with the --verbose option."
)

raise err


Expand Down

0 comments on commit 040a62c

Please sign in to comment.