Files
dragonpilot/system/hardware/tici/tests/test_hardware.py
Justin Newberry 0277fc5548 Pytest: consistent hardware state for tici tests (#31279)
* consistent hardware

* consistent hardware

* moved

* this too

* ruff

* s

* duplicated

---------

Co-authored-by: Comma Device <device@comma.ai>
2024-02-02 14:18:01 -08:00

29 lines
535 B
Python
Executable File

#!/usr/bin/env python3
import pytest
import time
import unittest
import numpy as np
from openpilot.system.hardware.tici.hardware import Tici
HARDWARE = Tici()
@pytest.mark.tici
class TestHardware(unittest.TestCase):
def test_power_save_time(self):
ts = []
for _ in range(5):
for on in (True, False):
st = time.monotonic()
HARDWARE.set_power_save(on)
ts.append(time.monotonic() - st)
assert 0.1 < np.mean(ts) < 0.25
assert max(ts) < 0.3
if __name__ == "__main__":
pytest.main()