You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							27 lines
						
					
					
						
							691 B
						
					
					
				
			
		
		
	
	
							27 lines
						
					
					
						
							691 B
						
					
					
				import os
 | 
						|
import unittest
 | 
						|
from uuid import uuid4
 | 
						|
 | 
						|
from openpilot.common.file_helpers import atomic_write_on_fs_tmp
 | 
						|
from openpilot.common.file_helpers import atomic_write_in_dir
 | 
						|
 | 
						|
 | 
						|
class TestFileHelpers(unittest.TestCase):
 | 
						|
  def run_atomic_write_func(self, atomic_write_func):
 | 
						|
    path = f"/tmp/tmp{uuid4()}"
 | 
						|
    with atomic_write_func(path) as f:
 | 
						|
      f.write("test")
 | 
						|
 | 
						|
    with open(path) as f:
 | 
						|
      self.assertEqual(f.read(), "test")
 | 
						|
    os.remove(path)
 | 
						|
 | 
						|
  def test_atomic_write_on_fs_tmp(self):
 | 
						|
    self.run_atomic_write_func(atomic_write_on_fs_tmp)
 | 
						|
 | 
						|
  def test_atomic_write_in_dir(self):
 | 
						|
    self.run_atomic_write_func(atomic_write_in_dir)
 | 
						|
 | 
						|
 | 
						|
if __name__ == "__main__":
 | 
						|
  unittest.main()
 | 
						|
 |