From c64b060c8082eec2a35ffc818d7ccf7cda9f140f Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Tue, 21 Apr 2026 22:56:25 -0700 Subject: [PATCH] unittest-parallel: add back missing tests (#3345) test missing stuff --- opendbc/can/tests/test_define.py | 8 +++++--- opendbc/car/honda/tests/test_honda.py | 3 ++- opendbc/car/rivian/tests/test_rivian.py | 8 +++++--- opendbc/car/subaru/tests/test_subaru.py | 4 +++- opendbc/car/tesla/tests/test_tesla.py | 4 +++- opendbc/car/toyota/tests/test_toyota.py | 26 +++++++++++++------------ 6 files changed, 32 insertions(+), 21 deletions(-) diff --git a/opendbc/can/tests/test_define.py b/opendbc/can/tests/test_define.py index 41cfa7899..92ad6e289 100644 --- a/opendbc/can/tests/test_define.py +++ b/opendbc/can/tests/test_define.py @@ -1,8 +1,10 @@ +import unittest + from opendbc.can import CANDefine from opendbc.can.tests import ALL_DBCS -class TestCANDefine: +class TestCANDefine(unittest.TestCase): def test_civic(self): dbc_file = "honda_civic_touring_2016_can_generated" @@ -20,8 +22,8 @@ class TestCANDefine: 0: 'NORMAL'} } - def test_all_dbcs(self, subtests): + def test_all_dbcs(self): # Asserts no exceptions on all DBCs for dbc in ALL_DBCS: - with subtests.test(dbc=dbc): + with self.subTest(dbc=dbc): CANDefine(dbc) diff --git a/opendbc/car/honda/tests/test_honda.py b/opendbc/car/honda/tests/test_honda.py index e72e6479b..c6301e676 100644 --- a/opendbc/car/honda/tests/test_honda.py +++ b/opendbc/car/honda/tests/test_honda.py @@ -1,4 +1,5 @@ import re +import unittest from opendbc.car.honda.fingerprints import FW_VERSIONS from opendbc.car.honda.values import HONDA_BOSCH, HONDA_BOSCH_TJA_CONTROL @@ -6,7 +7,7 @@ from opendbc.car.honda.values import HONDA_BOSCH, HONDA_BOSCH_TJA_CONTROL HONDA_FW_VERSION_RE = br"[A-Z0-9]{5}-[A-Z0-9]{3}(-|,)[A-Z0-9]{4}(\x00){2}$" -class TestHondaFingerprint: +class TestHondaFingerprint(unittest.TestCase): def test_fw_version_format(self): # Asserts all FW versions follow an expected format for fw_by_ecu in FW_VERSIONS.values(): diff --git a/opendbc/car/rivian/tests/test_rivian.py b/opendbc/car/rivian/tests/test_rivian.py index 7780638d3..37eca9918 100644 --- a/opendbc/car/rivian/tests/test_rivian.py +++ b/opendbc/car/rivian/tests/test_rivian.py @@ -1,11 +1,13 @@ +import unittest + from opendbc.car.rivian.fingerprints import FW_VERSIONS from opendbc.car.rivian.values import CAR, FW_QUERY_CONFIG, WMI, ModelLine, ModelYear -class TestRivian: - def test_custom_fuzzy_fingerprinting(self, subtests): +class TestRivian(unittest.TestCase): + def test_custom_fuzzy_fingerprinting(self): for platform in CAR: - with subtests.test(platform=platform.name): + with self.subTest(platform=platform.name): for wmi in WMI: for line in ModelLine: for year in ModelYear: diff --git a/opendbc/car/subaru/tests/test_subaru.py b/opendbc/car/subaru/tests/test_subaru.py index 7f3d9bb3c..399486648 100644 --- a/opendbc/car/subaru/tests/test_subaru.py +++ b/opendbc/car/subaru/tests/test_subaru.py @@ -1,7 +1,9 @@ +import unittest + from opendbc.car.subaru.fingerprints import FW_VERSIONS -class TestSubaruFingerprint: +class TestSubaruFingerprint(unittest.TestCase): def test_fw_version_format(self): for platform, fws_per_ecu in FW_VERSIONS.items(): for (ecu, _, _), fws in fws_per_ecu.items(): diff --git a/opendbc/car/tesla/tests/test_tesla.py b/opendbc/car/tesla/tests/test_tesla.py index f08a9dc97..2c7bc977d 100644 --- a/opendbc/car/tesla/tests/test_tesla.py +++ b/opendbc/car/tesla/tests/test_tesla.py @@ -1,4 +1,6 @@ import re +import unittest + from opendbc.car import gen_empty_fingerprint from opendbc.car.structs import CarParams from opendbc.car.tesla.interface import CarInterface @@ -52,7 +54,7 @@ FSD_14_FW_RULE = { } -class TestTeslaFingerprint: +class TestTeslaFingerprint(unittest.TestCase): def test_fw_platform_code(self): # Every EPS FW must parse and its platform letter must match the car it's filed under. for car_model, ecus in FW_VERSIONS.items(): diff --git a/opendbc/car/toyota/tests/test_toyota.py b/opendbc/car/toyota/tests/test_toyota.py index 2d07af548..f6443b200 100644 --- a/opendbc/car/toyota/tests/test_toyota.py +++ b/opendbc/car/toyota/tests/test_toyota.py @@ -1,3 +1,5 @@ +import unittest + from hypothesis import given, settings, strategies as st from opendbc.car import Bus @@ -16,7 +18,7 @@ def check_fw_version(fw_version: bytes) -> bool: return b'?' not in fw_version and b'!' not in fw_version -class TestToyotaInterfaces: +class TestToyotaInterfaces(unittest.TestCase): def test_car_sets(self): # Angle and radar-ACC cars are always TSS2 cars assert len(ANGLE_CONTROL_CAR - TSS2_CAR) == 0 @@ -33,11 +35,11 @@ class TestToyotaInterfaces: if car_model in TSS2_CAR and car_model not in SECOC_CAR: assert dbc[Bus.pt] == "toyota_nodsu_pt_generated" - def test_essential_ecus(self, subtests): + def test_essential_ecus(self): # Asserts standard ECUs exist for each platform common_ecus = {Ecu.fwdRadar, Ecu.fwdCamera} for car_model, ecus in FW_VERSIONS.items(): - with subtests.test(car_model=car_model.value): + with self.subTest(car_model=car_model.value): present_ecus = {ecu[0] for ecu in ecus} missing_ecus = common_ecus - present_ecus assert len(missing_ecus) == 0 @@ -53,19 +55,19 @@ class TestToyotaInterfaces: assert Ecu.eps in present_ecus -class TestToyotaFingerprint: - def test_non_essential_ecus(self, subtests): +class TestToyotaFingerprint(unittest.TestCase): + def test_non_essential_ecus(self): # Ensures only the cars that have multiple engine ECUs are in the engine non-essential ECU list for car_model, ecus in FW_VERSIONS.items(): - with subtests.test(car_model=car_model.value): + with self.subTest(car_model=car_model.value): engine_ecus = {ecu for ecu in ecus if ecu[0] == Ecu.engine} assert (len(engine_ecus) > 1) == (car_model in FW_QUERY_CONFIG.non_essential_ecus[Ecu.engine]), \ f"Car model unexpectedly {'not ' if len(engine_ecus) > 1 else ''}in non-essential list" - def test_valid_fw_versions(self, subtests): + def test_valid_fw_versions(self): # Asserts all FW versions are valid for car_model, ecus in FW_VERSIONS.items(): - with subtests.test(car_model=car_model.value): + with self.subTest(car_model=car_model.value): for fws in ecus.values(): for fw in fws: assert check_fw_version(fw), fw @@ -79,10 +81,10 @@ class TestToyotaFingerprint: fws = data.draw(fw_strategy) get_platform_codes(fws) - def test_platform_code_ecus_available(self, subtests): + def test_platform_code_ecus_available(self): # Asserts ECU keys essential for fuzzy fingerprinting are available on all platforms for car_model, ecus in FW_VERSIONS.items(): - with subtests.test(car_model=car_model.value): + with self.subTest(car_model=car_model.value): for platform_code_ecu in PLATFORM_CODE_ECUS: if platform_code_ecu == Ecu.eps and car_model in (CAR.TOYOTA_PRIUS_V, CAR.LEXUS_CTH,): continue @@ -90,14 +92,14 @@ class TestToyotaFingerprint: continue assert platform_code_ecu in [e[0] for e in ecus] - def test_fw_format(self, subtests): + def test_fw_format(self): # Asserts: # - every supported ECU FW version returns one platform code # - every supported ECU FW version has a part number # - expected parsing of ECU sub-versions for car_model, ecus in FW_VERSIONS.items(): - with subtests.test(car_model=car_model.value): + with self.subTest(car_model=car_model.value): for ecu, fws in ecus.items(): if ecu[0] not in PLATFORM_CODE_ECUS: continue