test_navd: parameterize random test (#31376)

* parameterized

* import

* dumb
pull/31379/head
Justin Newberry 1 year ago committed by GitHub
parent 70288d1742
commit 1c201295c7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      selfdrive/manager/test/test_manager.py
  2. 12
      selfdrive/navd/tests/test_navd.py

@ -40,7 +40,7 @@ class TestManager(unittest.TestCase):
# TODO: ensure there are blacklisted procs until we have a dedicated test # TODO: ensure there are blacklisted procs until we have a dedicated test
self.assertTrue(len(BLACKLIST_PROCS), "No blacklisted procs to test not_run") self.assertTrue(len(BLACKLIST_PROCS), "No blacklisted procs to test not_run")
@parameterized.expand(range(10)) @parameterized.expand([(i,) for i in range(10)])
def test_startup_time(self, index): def test_startup_time(self, index):
start = time.monotonic() start = time.monotonic()
os.environ['PREPAREONLY'] = '1' os.environ['PREPAREONLY'] = '1'

@ -4,6 +4,8 @@ import random
import unittest import unittest
import numpy as np import numpy as np
from parameterized import parameterized
import cereal.messaging as messaging import cereal.messaging as messaging
from openpilot.common.params import Params from openpilot.common.params import Params
from openpilot.selfdrive.manager.process_config import managed_processes from openpilot.selfdrive.manager.process_config import managed_processes
@ -50,11 +52,11 @@ class TestNavd(unittest.TestCase):
} }
self._check_route(start, end) self._check_route(start, end)
def test_random(self): @parameterized.expand([(i,) for i in range(10)])
for _ in range(10): def test_random(self, index):
start = {"latitude": random.uniform(-90, 90), "longitude": random.uniform(-180, 180)} start = {"latitude": random.uniform(-90, 90), "longitude": random.uniform(-180, 180)}
end = {"latitude": random.uniform(-90, 90), "longitude": random.uniform(-180, 180)} end = {"latitude": random.uniform(-90, 90), "longitude": random.uniform(-180, 180)}
self._check_route(start, end, check_coords=False) self._check_route(start, end, check_coords=False)
if __name__ == "__main__": if __name__ == "__main__":

Loading…
Cancel
Save