22 lines
575 B
Python
22 lines
575 B
Python
from __future__ import annotations
|
|
|
|
import unittest
|
|
|
|
from scripts.hardware_probe import read_optional_text
|
|
|
|
|
|
class HardwareProbeTests(unittest.TestCase):
|
|
def test_optional_sysfs_read_tolerates_kernel_read_errors(self) -> None:
|
|
class BrokenSysfsPath:
|
|
def is_file(self) -> bool:
|
|
return True
|
|
|
|
def read_text(self, *args: object, **kwargs: object) -> str:
|
|
raise OSError(22, "Invalid argument")
|
|
|
|
self.assertEqual(read_optional_text(BrokenSysfsPath()), "")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|