@@ -34,6 +34,7 @@ def test_get_api_endpoint_gets_domain_from_pythonanywhere_site_and_ignores_pytho
3434def test_get_api_endpoint_gets_domain_from_pythonanywhere_domain_and_adds_on_www_if_set_but_pythonanywhere_site_is_not (
3535 monkeypatch
3636):
37+ monkeypatch .delenv ("PYTHONANYWHERE_SITE" , raising = False )
3738 monkeypatch .setenv ("PYTHONANYWHERE_DOMAIN" , "foo.com" )
3839
3940 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):
8182 assert kwargs ["verify" ] is True
8283
8384
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 ):
8586 mock_helpful_message = mocker .patch ("pythonanywhere_core.base.helpful_token_error_message" )
8687 mock_helpful_message .return_value = "I'm so helpful"
8788
89+ monkeypatch .delenv ("API_TOKEN" , raising = False )
90+
8891 with pytest .raises (NoTokenError ) as exc :
8992 call_api ("blah" , "get" )
9093
@@ -97,5 +100,7 @@ def test_helpful_message_inside_pythonanywhere(monkeypatch):
97100 assert "Oops, you don't seem to have an API token." in helpful_token_error_message ()
98101
99102
100- def test_helpful_message_outside_pythonanywhere ():
103+ def test_helpful_message_outside_pythonanywhere (monkeypatch ):
104+ monkeypatch .delenv ("PYTHONANYWHERE_SITE" , raising = False )
105+
101106 assert "Oops, you don't seem to have an API_TOKEN environment variable set." in helpful_token_error_message ()
0 commit comments