Skip to content

Commit cbacbbe

Browse files
Stop printing API authentication failures to stdout.
1 parent ec52d9c commit cbacbbe

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

‎pythonanywhere_core/base.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,5 @@ def call_api(url: str, method: str, **kwargs) -> requests.Response:
9696
**kwargs,
9797
)
9898
if response.status_code == 401:
99-
print(response, response.text)
10099
raise AuthenticationError(f"Authentication error {response.status_code} calling API: {response.text}")
101100
return response

‎tests/test_base.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,13 @@ def test_get_api_endpoint_returns_url_with_correct_api_version(flavor, expected_
7070
assert result == f"https://www.pythonanywhere.com/api/{expected_version}/user/bill/{flavor}/"
7171

7272

73-
def test_raises_on_401(api_token, api_responses):
73+
def test_raises_on_401_without_printing(api_token, api_responses, capsys):
7474
url = "https://foo.com/"
7575
api_responses.add(responses.POST, url, status=401, body="nope")
7676
with pytest.raises(AuthenticationError) as e:
7777
call_api(url, "post")
7878
assert str(e.value) == "Authentication error 401 calling API: nope"
79+
assert capsys.readouterr().out == ""
7980

8081

8182

0 commit comments

Comments
 (0)