1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 21:06:19 +00:00

Use atomicwrites for mission critical core files (#59606)

This commit is contained in:
J. Nick Koston
2021-11-15 04:19:31 -06:00
committed by GitHub
parent 04a258bf21
commit 96f7b0d910
19 changed files with 92 additions and 24 deletions

View File

@@ -67,11 +67,12 @@ def test_save_and_load_private():
assert stats.st_mode & 0o77 == 0
def test_overwrite_and_reload():
@pytest.mark.parametrize("atomic_writes", [True, False])
def test_overwrite_and_reload(atomic_writes):
"""Test that we can overwrite an existing file and read back."""
fname = _path_for("test3")
save_json(fname, TEST_JSON_A)
save_json(fname, TEST_JSON_B)
save_json(fname, TEST_JSON_A, atomic_writes=atomic_writes)
save_json(fname, TEST_JSON_B, atomic_writes=atomic_writes)
data = load_json(fname)
assert data == TEST_JSON_B