Skip to content
This repository was archived by the owner on Mar 31, 2026. It is now read-only.

Commit 2e70a58

Browse files
authored
tests: fix unit tests broken by dependency drift (#430)
* tests: fix 'TestClient.test_ctor_wo_project' Broken by googleapis/python-cloud-core#51 Closes #427 * chore(deps): pin googleapis-common-protos' FBO python2.7 Closes #429
1 parent 9777904 commit 2e70a58

2 files changed

Lines changed: 7 additions & 8 deletions

File tree

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"google-cloud-core >= 1.4.1, < 2.0dev",
3333
"google-resumable-media >= 1.2.0, < 2.0dev",
3434
"requests >= 2.18.0, < 3.0.0dev",
35+
"googleapis-common-protos < 1.53.0; python_version<'3.0'",
3536
]
3637
extras = {}
3738

tests/unit/test_client.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,12 @@
3939
_FAKE_CREDENTIALS = Credentials.from_service_account_info(_SERVICE_ACCOUNT_JSON)
4040

4141

42-
def _make_credentials():
42+
def _make_credentials(project=None):
4343
import google.auth.credentials
4444

45+
if project is not None:
46+
return mock.Mock(spec=google.auth.credentials.Credentials, project_id=project)
47+
4548
return mock.Mock(spec=google.auth.credentials.Credentials)
4649

4750

@@ -174,14 +177,9 @@ def test_ctor_wo_project(self):
174177
from google.cloud.storage._http import Connection
175178

176179
PROJECT = "PROJECT"
177-
credentials = _make_credentials()
180+
credentials = _make_credentials(project=PROJECT)
178181

179-
ddp_patch = mock.patch(
180-
"google.cloud.client._determine_default_project", return_value=PROJECT
181-
)
182-
183-
with ddp_patch:
184-
client = self._make_one(credentials=credentials)
182+
client = self._make_one(credentials=credentials)
185183

186184
self.assertEqual(client.project, PROJECT)
187185
self.assertIsInstance(client._connection, Connection)

0 commit comments

Comments
 (0)