openpilot is an open source driver assistance system. openpilot performs the functions of Automated Lane Centering and Adaptive Cruise Control for over 200 supported car makes and models.

20 lines
476 B

6 years ago
import os
from uuid import uuid4
from openpilot.common.file_helpers import atomic_write_in_dir
6 years ago
class TestFileHelpers:
6 years ago
def run_atomic_write_func(self, atomic_write_func):
path = f"/tmp/tmp{uuid4()}"
6 years ago
with atomic_write_func(path) as f:
f.write("test")
assert not os.path.exists(path)
6 years ago
with open(path) as f:
assert f.read() == "test"
6 years ago
os.remove(path)
def test_atomic_write_in_dir(self):
self.run_atomic_write_func(atomic_write_in_dir)