|
3 | 3 | import re
|
4 | 4 | import time
|
5 | 5 | import pytest
|
6 |
| -from pytest import MonkeyPatch |
7 | 6 |
|
8 | 7 | from pydrive2.auth import AuthenticationError, GoogleAuth
|
9 | 8 | from pydrive2.test.test_util import (
|
@@ -190,25 +189,24 @@ def test_12_ServiceAuthFromJsonDictNoCredentialsSaving():
|
190 | 189 | time.sleep(1)
|
191 | 190 |
|
192 | 191 |
|
193 |
| -def test_13_LocalWebServerAuthNonInterativeRaises(): |
| 192 | +def test_13_LocalWebServerAuthNonInterativeRaises(monkeypatch): |
194 | 193 | settings = {
|
195 | 194 | "client_config_backend": "file",
|
196 | 195 | "client_config_file": "client_secrets.json",
|
197 | 196 | "oauth_scope": ["https://www.googleapis.com/auth/drive"],
|
198 | 197 | }
|
199 | 198 | ga = GoogleAuth(settings=settings)
|
200 | 199 |
|
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() |
212 | 210 |
|
213 | 211 |
|
214 | 212 | def CheckCredentialsFile(credentials, no_file=False):
|
|
0 commit comments