Skip to content

Commit 620043b

Browse files
committed
Patched os.environ in the unit test
1 parent bfe1e98 commit 620043b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

tests/unit/aiplatform/test_initializer.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,18 @@ def mock_auth_default():
6363
assert initializer.global_config.project == _TEST_PROJECT
6464

6565
def test_infer_project_id(self):
66-
def mock_get_project_id():
66+
cloud_project_number = 123
67+
68+
def mock_get_project_id(project_number: str, **_):
69+
assert project_number == cloud_project_number
6770
return _TEST_PROJECT
6871

6972
with mock.patch.object(
7073
target=resource_manager_utils,
7174
attribute="get_project_id",
7275
new=mock_get_project_id,
76+
), mock.patch.dict(
77+
os.environ, {"CLOUD_ML_PROJECT_ID": cloud_project_number}, clear=True
7378
):
7479
assert initializer.global_config.project == _TEST_PROJECT
7580

0 commit comments

Comments
 (0)