@@ -34,6 +34,7 @@ def test_get_api_endpoint_gets_domain_from_pythonanywhere_site_and_ignores_pytho
34
34
def test_get_api_endpoint_gets_domain_from_pythonanywhere_domain_and_adds_on_www_if_set_but_pythonanywhere_site_is_not (
35
35
monkeypatch
36
36
):
37
+ monkeypatch .delenv ("PYTHONANYWHERE_SITE" , raising = False )
37
38
monkeypatch .setenv ("PYTHONANYWHERE_DOMAIN" , "foo.com" )
38
39
39
40
result = get_api_endpoint (username = "bill" , flavor = "webapp" )
@@ -81,10 +82,12 @@ def test_verify_is_true_if_env_not_set(api_token, mock_requests):
81
82
assert kwargs ["verify" ] is True
82
83
83
84
84
- def test_raises_with_helpful_message_if_no_token_present (mocker ):
85
+ def test_raises_with_helpful_message_if_no_token_present (mocker , monkeypatch ):
85
86
mock_helpful_message = mocker .patch ("pythonanywhere_core.base.helpful_token_error_message" )
86
87
mock_helpful_message .return_value = "I'm so helpful"
87
88
89
+ monkeypatch .delenv ("API_TOKEN" , raising = False )
90
+
88
91
with pytest .raises (NoTokenError ) as exc :
89
92
call_api ("blah" , "get" )
90
93
@@ -97,5 +100,7 @@ def test_helpful_message_inside_pythonanywhere(monkeypatch):
97
100
assert "Oops, you don't seem to have an API token." in helpful_token_error_message ()
98
101
99
102
100
- def test_helpful_message_outside_pythonanywhere ():
103
+ def test_helpful_message_outside_pythonanywhere (monkeypatch ):
104
+ monkeypatch .delenv ("PYTHONANYWHERE_SITE" , raising = False )
105
+
101
106
assert "Oops, you don't seem to have an API_TOKEN environment variable set." in helpful_token_error_message ()
0 commit comments