Skip to content

Commit 9ba877c

Browse files
committed
use monkeypatch to avoid rouge env vars
1 parent 99a4a65 commit 9ba877c

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

clients/python/test/test_osparc/test_basic.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import json
2-
import os
32
import subprocess
43
from pathlib import Path
54
from typing import Any, Dict, List, Set
6-
5+
from faker import Faker
76
import osparc
87
import osparc._settings
98
import pydantic
@@ -75,15 +74,17 @@ def test_dependencies(tmp_path: Path):
7574

7675

7776
@pytest.mark.parametrize("valid", [True, False])
78-
def test_parent_project_validation(faker, valid: bool):
77+
def test_parent_project_validation(
78+
faker: Faker, monkeypatch: pytest.MonkeyPatch, valid: bool
79+
):
7980
if valid:
80-
os.environ["OSPARC_STUDY_ID"] = f"{faker.uuid4()}"
81-
os.environ["OSPARC_NODE_ID"] = f"{faker.uuid4()}"
81+
monkeypatch.setenv("OSPARC_STUDY_ID", faker.uuid4())
82+
monkeypatch.setenv("OSPARC_NODE_ID", faker.uuid4())
8283
parent_info = osparc._settings.ParentProjectInfo()
8384
assert parent_info.x_simcore_parent_project_uuid is not None
8485
assert parent_info.x_simcore_parent_node_id is not None
8586
else:
86-
os.environ["OSPARC_STUDY_ID"] = f"{faker.text()}"
87-
os.environ["OSPARC_NODE_ID"] = f"{faker.text()}"
87+
monkeypatch.setenv("OSPARC_STUDY_ID", faker.text())
88+
monkeypatch.setenv("OSPARC_NODE_ID", faker.text())
8889
with pytest.raises(pydantic.ValidationError):
8990
_ = osparc._settings.ParentProjectInfo()

0 commit comments

Comments
 (0)