返回 last30days-skill
test_env_file_utf8.py
根目录 / tests / test_env_file_utf8.py
1 from lib import env
2
3
4 def test_load_env_file_reads_utf8_regardless_of_locale(tmp_path):
5 # setup_wizard writes .env with encoding="utf-8"; the loader must read it
6 # back with the same encoding instead of the platform default (cp1252 on
7 # most Windows locales), or non-ASCII values raise UnicodeDecodeError.
8 env_path = tmp_path / ".env"
9 env_path.write_text(
10 "# café notes ☕\nDISPLAY_NAME=Zoë\nAPI_LABEL=日本語キー\n",
11 encoding="utf-8",
12 )
13
14 loaded = env.load_env_file(env_path)
15
16 assert loaded["DISPLAY_NAME"] == "Zoë"
17 assert loaded["API_LABEL"] == "日本語キー"
18
18 lines PYTHON