Skip to content

Commit 4b7dd7e

Browse files
committed
test: stop test_init_from_env_vars leaking OSW_CRED_FILEPATH
- use monkeypatch.setenv so OSW_CRED_FILEPATH and OSW_DOMAIN are restored - the test unlinks its credential file, so the leaked path pointed every later test at a missing file - surfaced by the mcp de-isolation: tests/integration/test_mcp_server.py no longer skips for a missing SDK, so it hit the polluted environment
1 parent 4a933af commit 4b7dd7e

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

‎tests/integration/test_express.py‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
* test_upload_file
2323
"""
2424

25-
import os
2625
import uuid
2726
from contextlib import contextmanager
2827
from pathlib import Path
@@ -102,11 +101,13 @@ def test_init_with_domain(wiki_domain, wiki_username, wiki_password, mocker):
102101
osw_express.shut_down()
103102

104103

105-
def test_init_from_env_vars(wiki_domain, wiki_username, wiki_password):
104+
def test_init_from_env_vars(monkeypatch, wiki_domain, wiki_username, wiki_password):
105+
# monkeypatch, not os.environ: the file is unlinked at the end of this test, so
106+
# a leaked OSW_CRED_FILEPATH would point every later test at a missing file.
106107
cred_filepath = Path.cwd() / "accounts.pwd.yaml"
107-
os.environ["OSW_CRED_FILEPATH"] = str(cred_filepath)
108+
monkeypatch.setenv("OSW_CRED_FILEPATH", str(cred_filepath))
108109
create_credentials_file(cred_filepath, wiki_domain, wiki_username, wiki_password)
109-
os.environ["OSW_DOMAIN"] = wiki_domain
110+
monkeypatch.setenv("OSW_DOMAIN", wiki_domain)
110111

111112
osw_express = osw.express.OswExpress()
112113
osw_express_and_credentials(osw_express, wiki_domain, wiki_username, wiki_password)

0 commit comments

Comments
 (0)