test: make the API-key fixture robust to empty-string env vars

A key left blank in a .env (var present but empty) bypassed the placeholder,
so local runs diverged from CI. Use 'or' instead of a .get default.
This commit is contained in:
Yijia-Xiao
2026-06-21 23:50:33 +00:00
parent 2b2d685df6
commit 8ab24f30af

View File

@@ -32,7 +32,9 @@ _API_KEY_ENV_VARS = (
@pytest.fixture(autouse=True)
def _dummy_api_keys(monkeypatch):
for env_var in _API_KEY_ENV_VARS:
monkeypatch.setenv(env_var, os.environ.get(env_var, "placeholder"))
# `or` not a .get default: an env var present but empty (e.g. a key left
# blank in a .env copied from .env.example) must still get the placeholder.
monkeypatch.setenv(env_var, os.environ.get(env_var) or "placeholder")
@pytest.fixture(autouse=True)