test: add unicode preservation and round-trip tests for save_vault_yaml
Add tests verifying allow_unicode=True behavior: - test_save_preserves_unicode: non-ASCII content (Cyrillic, German umlaut, Chinese) is written as UTF-8, not \uXXXX escapes - test_save_unicode_round_trip: saved unicode data loads back correctly Also add CHANGELOG entry under [Unreleased] > Fixed. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
parent
ac0ce1c158
commit
3f223d5657
@@ -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