Skip to content

Commit 1e252e2

Browse files
committed
test(storage): isolate environment in client tests
1 parent ef62df4 commit 1e252e2

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

packages/google-cloud-storage/tests/unit/test_client.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,8 @@ def test_ctor_wo_project(self):
300300
PROJECT = "PROJECT"
301301
credentials = _make_credentials(project=PROJECT)
302302

303-
client = self._make_one(credentials=credentials)
303+
with mock.patch("os.environ", {}):
304+
client = self._make_one(credentials=credentials)
304305

305306
self.assertEqual(client.project, PROJECT)
306307
self.assertIsInstance(client._connection, Connection)
@@ -368,10 +369,11 @@ def test_ctor_w_custom_endpoint_use_auth(self):
368369

369370
def test_ctor_w_custom_endpoint_bypass_auth(self):
370371
custom_endpoint = "storage-example.p.googleapis.com"
371-
client = self._make_one(
372-
client_options={"api_endpoint": custom_endpoint},
373-
use_auth_w_custom_endpoint=False,
374-
)
372+
with mock.patch("os.environ", {}):
373+
client = self._make_one(
374+
client_options={"api_endpoint": custom_endpoint},
375+
use_auth_w_custom_endpoint=False,
376+
)
375377
self.assertEqual(client._connection.API_BASE_URL, custom_endpoint)
376378
self.assertEqual(client.project, None)
377379
self.assertIsInstance(client._connection, Connection)
@@ -381,9 +383,10 @@ def test_ctor_w_custom_endpoint_w_credentials(self):
381383
PROJECT = "PROJECT"
382384
custom_endpoint = "storage-example.p.googleapis.com"
383385
credentials = _make_credentials(project=PROJECT)
384-
client = self._make_one(
385-
credentials=credentials, client_options={"api_endpoint": custom_endpoint}
386-
)
386+
with mock.patch("os.environ", {}):
387+
client = self._make_one(
388+
credentials=credentials, client_options={"api_endpoint": custom_endpoint}
389+
)
387390
self.assertEqual(client._connection.API_BASE_URL, custom_endpoint)
388391
self.assertEqual(client.project, PROJECT)
389392
self.assertIsInstance(client._connection, Connection)

0 commit comments

Comments
 (0)