Skip to content

Commit 45517d6

Browse files
authored
test(ndb): fix project ID leak in tests (#16753)
This PR fixes a project ID leak in NDB tests where environment variables were not cleared, causing failures when run against core dependencies at HEAD.
1 parent 955a91b commit 45517d6

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ def test_constructor_no_args_emulator():
5656
patch_environ = mock.patch.dict(
5757
"google.cloud.ndb.client.os.environ",
5858
{"DATASTORE_EMULATOR_HOST": "foo"},
59+
clear=True,
5960
)
6061
with patch_environ:
6162
with patch_credentials("testing"):
@@ -69,9 +70,14 @@ def test_constructor_no_args_emulator():
6970

7071
@staticmethod
7172
def test_constructor_get_project_from_environ(environ):
72-
environ[environment_vars.GCD_DATASET] = "gcd-project"
73-
with patch_credentials(None):
74-
client = client_module.Client()
73+
patch_environ = mock.patch.dict(
74+
"google.cloud.ndb.client.os.environ",
75+
{environment_vars.GCD_DATASET: "gcd-project"},
76+
clear=True,
77+
)
78+
with patch_environ:
79+
with patch_credentials(None):
80+
client = client_module.Client()
7581
assert client.project == "gcd-project"
7682

7783
@staticmethod

0 commit comments

Comments
 (0)