Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3f223d5657 | ||
|
|
ac0ce1c158 |
@@ -16,6 +16,11 @@ All notable changes to this project will be documented in this file.
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Fixed
|
||||
|
||||
- `save_vault_yaml`: pass `allow_unicode=True` to `yaml.dump` to prevent
|
||||
corruption of non-ASCII vault content (matches infra's `save_yaml` pattern)
|
||||
|
||||
### Ci
|
||||
|
||||
- Add composite actions (setup-env, notify-failure, quality-checks) in `.gitea/actions/`
|
||||
|
||||
@@ -102,7 +102,7 @@ def save_vault_yaml(path: Path, data: dict, vault_pass: Path | None = None) -> N
|
||||
data: Data to serialize.
|
||||
vault_pass: Path to the vault-password file (optional).
|
||||
"""
|
||||
plain = yaml.dump(data, default_flow_style=False, sort_keys=False)
|
||||
plain = yaml.dump(data, default_flow_style=False, sort_keys=False, allow_unicode=True)
|
||||
with open(path, "w", encoding="utf-8") as f:
|
||||
f.write(plain)
|
||||
if vault_pass is not None and vault_pass.exists():
|
||||
|
||||
@@ -75,6 +75,25 @@ class TestSaveVaultYaml:
|
||||
content = f.read_text()
|
||||
assert "key: value" in content
|
||||
|
||||
def test_save_preserves_unicode(self, tmp_path: Path) -> None:
|
||||
"""allow_unicode=True writes UTF-8 instead of \\uXXXX escapes."""
|
||||
f = tmp_path / "output.yml"
|
||||
data = {"name": "Тест", "city": "München", "role": "管理员"}
|
||||
save_vault_yaml(f, data)
|
||||
content = f.read_text()
|
||||
assert "Тест" in content
|
||||
assert "München" in content
|
||||
assert "管理员" in content
|
||||
assert "\\u" not in content
|
||||
|
||||
def test_save_unicode_round_trip(self, tmp_path: Path) -> None:
|
||||
"""Saved unicode data loads back correctly."""
|
||||
f = tmp_path / "output.yml"
|
||||
data = {"name": "Тест", "city": "München"}
|
||||
save_vault_yaml(f, data)
|
||||
loaded = load_vault_yaml(f)
|
||||
assert loaded == data
|
||||
|
||||
def test_save_with_vault_pass_not_exists(self, tmp_path: Path) -> None:
|
||||
f = tmp_path / "output.yml"
|
||||
vp = tmp_path / "nonexistent"
|
||||
|
||||
Reference in New Issue
Block a user