Skip to content

Commit 1a8cd72

Browse files
skshetryefiop
authored andcommitted
test: use monkeypatch fixture
1 parent 36746bb commit 1a8cd72

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

pydrive2/test/test_oauth.py

+11-13
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import re
44
import time
55
import pytest
6-
from pytest import MonkeyPatch
76

87
from pydrive2.auth import AuthenticationError, GoogleAuth
98
from pydrive2.test.test_util import (
@@ -190,25 +189,24 @@ def test_12_ServiceAuthFromJsonDictNoCredentialsSaving():
190189
time.sleep(1)
191190

192191

193-
def test_13_LocalWebServerAuthNonInterativeRaises():
192+
def test_13_LocalWebServerAuthNonInterativeRaises(monkeypatch):
194193
settings = {
195194
"client_config_backend": "file",
196195
"client_config_file": "client_secrets.json",
197196
"oauth_scope": ["https://www.googleapis.com/auth/drive"],
198197
}
199198
ga = GoogleAuth(settings=settings)
200199

201-
with MonkeyPatch.context() as m:
202-
m.setenv("GDRIVE_NON_INTERACTIVE", "true")
203-
# Test that exception is raised on trying to do browser auth if
204-
# we are running in a non interactive environment.
205-
with pytest.raises(
206-
AuthenticationError,
207-
match=re.escape(
208-
"Non interactive mode (GDRIVE_NON_INTERACTIVE env) is enabled"
209-
),
210-
):
211-
ga.LocalWebserverAuth()
200+
monkeypatch.setenv("GDRIVE_NON_INTERACTIVE", "true")
201+
# Test that exception is raised on trying to do browser auth if
202+
# we are running in a non interactive environment.
203+
with pytest.raises(
204+
AuthenticationError,
205+
match=re.escape(
206+
"Non interactive mode (GDRIVE_NON_INTERACTIVE env) is enabled"
207+
),
208+
):
209+
ga.LocalWebserverAuth()
212210

213211

214212
def CheckCredentialsFile(credentials, no_file=False):

0 commit comments

Comments
 (0)