20 lines
640 B
Python
20 lines
640 B
Python
"""本机 .env 只补缺,不覆盖已有环境变量。"""
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
|
|
from app.local_env import load_local_env
|
|
|
|
|
|
def test_load_local_env_fills_missing_and_keeps_existing(tmp_path, monkeypatch):
|
|
monkeypatch.setenv("OMS_REPO", "memory")
|
|
monkeypatch.delenv("RPA_ORACLE_PASSWORD", raising=False)
|
|
env_file = tmp_path / ".env"
|
|
env_file.write_text(
|
|
"OMS_REPO=oracle\nRPA_ORACLE_PASSWORD=not-for-git\n# comment\n\n",
|
|
encoding="utf-8",
|
|
)
|
|
load_local_env(env_file)
|
|
assert os.environ["OMS_REPO"] == "memory"
|
|
assert os.environ["RPA_ORACLE_PASSWORD"] == "not-for-git"
|