Skip to content

Commit

Permalink
Patched os.environ in the unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Ark-kun committed Mar 17, 2022
1 parent bfe1e98 commit 620043b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tests/unit/aiplatform/test_initializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,18 @@ def mock_auth_default():
assert initializer.global_config.project == _TEST_PROJECT

def test_infer_project_id(self):
def mock_get_project_id():
cloud_project_number = 123

def mock_get_project_id(project_number: str, **_):
assert project_number == cloud_project_number
return _TEST_PROJECT

with mock.patch.object(
target=resource_manager_utils,
attribute="get_project_id",
new=mock_get_project_id,
), mock.patch.dict(
os.environ, {"CLOUD_ML_PROJECT_ID": cloud_project_number}, clear=True
):
assert initializer.global_config.project == _TEST_PROJECT

Expand Down

0 comments on commit 620043b

Please sign in to comment.