mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-07-13 00:42:07 +08:00
161005a0c1
date: 2025-11-19T19:10:11 master commit: a29fdbd02407d41ecbcc69d151bb4837bfba3cbc
20 lines
469 B
Python
20 lines
469 B
Python
import os
|
|
from uuid import uuid4
|
|
|
|
from openpilot.common.utils import atomic_write_in_dir
|
|
|
|
|
|
class TestFileHelpers:
|
|
def run_atomic_write_func(self, atomic_write_func):
|
|
path = f"/tmp/tmp{uuid4()}"
|
|
with atomic_write_func(path) as f:
|
|
f.write("test")
|
|
assert not os.path.exists(path)
|
|
|
|
with open(path) as f:
|
|
assert f.read() == "test"
|
|
os.remove(path)
|
|
|
|
def test_atomic_write_in_dir(self):
|
|
self.run_atomic_write_func(atomic_write_in_dir)
|