Skip to content

Commit

Permalink
Fix integration test of PyPI error message (#867)
Browse files Browse the repository at this point in the history
  • Loading branch information
bhrutledge authored Feb 5, 2022
1 parent 133f8ae commit 37a3f87
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import subprocess
import sys

import colorama
import jaraco.envs
import munch
import portend
Expand Down Expand Up @@ -64,7 +63,7 @@ def test_pypi_upload(sampleproject_dist):
cli.dispatch(command)


def test_pypi_error(sampleproject_dist, monkeypatch):
def test_pypi_error(sampleproject_dist, monkeypatch, capsys):
command = [
"twine",
"upload",
Expand All @@ -79,14 +78,16 @@ def test_pypi_error(sampleproject_dist, monkeypatch):
monkeypatch.setattr(sys, "argv", command)

message = (
re.escape(colorama.Fore.RED)
+ r"HTTPError: 403 Forbidden from https://test\.pypi\.org/legacy/\n"
+ r".+?authentication"
r"HTTPError: 403 Forbidden from https://test\.pypi\.org/legacy/"
+ r".+authentication information"
)

result = dunder_main.main()
error = dunder_main.main()
assert error

assert re.match(message, result)
captured = capsys.readouterr()

assert re.search(message, captured.out, re.DOTALL)


@pytest.fixture(
Expand Down

0 comments on commit 37a3f87

Please sign in to comment.