From 7e1718cec74b44bb9aacc45c3bd245c953e692df Mon Sep 17 00:00:00 2001 From: firestar5683 <168790843+firestar5683@users.noreply.github.com> Date: Sat, 28 Nov 2026 16:36:08 -0600 Subject: [PATCH] Restore Hyundai Safety Test Fixtures --- .../tests/test_hyundai_classic_long_aol.py | 20 +++++-------------- .../tests/test_hyundai_grouped_non_scc_aol.py | 8 +------- .../safety/tests/test_hyundai_main_rearm.py | 10 +--------- .../safety/tests/test_nexo_stock_aol.py | 10 ++-------- prebuilt.json | 2 +- 5 files changed, 10 insertions(+), 40 deletions(-) diff --git a/opendbc_repo/opendbc/safety/tests/test_hyundai_classic_long_aol.py b/opendbc_repo/opendbc/safety/tests/test_hyundai_classic_long_aol.py index f4e117194e..af5e5645ab 100644 --- a/opendbc_repo/opendbc/safety/tests/test_hyundai_classic_long_aol.py +++ b/opendbc_repo/opendbc/safety/tests/test_hyundai_classic_long_aol.py @@ -1,17 +1,12 @@ from opendbc.car.structs import CarParams -import unittest from opendbc.safety.tests import test_hyundai_kona_lda_aol as fixture -class TestHyundaiClassicLongAol(unittest.TestCase): +class ClassicLongAolFixture(fixture.KonaAolFixture): def setUp(self): - fixture.TestHyundaiKonaLdaAol.setUp(self) + super().setUp() self.release = self.safety.set_safety_hooks(CarParams.SafetyModel.allOutput, 0) != 0 - tearDown = fixture.TestHyundaiKonaLdaAol.tearDown - reset = fixture.TestHyundaiKonaLdaAol.reset - rx = fixture.TestHyundaiKonaLdaAol.rx - request = fixture.TestHyundaiKonaLdaAol.request def feed(self, word=0x404, button=0, main=False, available=True, tcs=True, clu=True, wrong_bus=None, corrupt_tcs=False): self.safety.set_timer(self.now) @@ -29,6 +24,8 @@ class TestHyundaiClassicLongAol(unittest.TestCase): self.rx('CLU11', {'CF_Clu_AliveCnt1': c % 16, 'CF_Clu_CruiseSwState': button, 'CF_Clu_CruiseSwMain': int(main)}) self.now += 10000 + +class TestHyundaiClassicLongAol(ClassicLongAolFixture): def test_marked_long_with_foreign_experience_has_no_rx_or_tx_admission(self): for experience in (0, 1, 33): self.safety.set_alternative_experience(experience) @@ -134,14 +131,7 @@ class TestHyundaiClassicLongAol(unittest.TestCase): self.assertEqual(self.request(3), 0) -class TestHyundaiLegacyLongAol(unittest.TestCase): - setUp = TestHyundaiClassicLongAol.setUp - tearDown = TestHyundaiClassicLongAol.tearDown - reset = TestHyundaiClassicLongAol.reset - rx = TestHyundaiClassicLongAol.rx - request = TestHyundaiClassicLongAol.request - feed = TestHyundaiClassicLongAol.feed - +class TestHyundaiLegacyLongAol(ClassicLongAolFixture): def test_legacy_lda_bit_selects_real_physical_source_without_longitudinal_grant(self): for word in (0xE902, 0xE903, 0xE912, 0xE913): for source, signal in (('BCM_PO_11', 'LDA_BTN'), ('CLU13', 'CF_Clu_LdwsLkasSW')): diff --git a/opendbc_repo/opendbc/safety/tests/test_hyundai_grouped_non_scc_aol.py b/opendbc_repo/opendbc/safety/tests/test_hyundai_grouped_non_scc_aol.py index e0775a60e8..ec13392edd 100644 --- a/opendbc_repo/opendbc/safety/tests/test_hyundai_grouped_non_scc_aol.py +++ b/opendbc_repo/opendbc/safety/tests/test_hyundai_grouped_non_scc_aol.py @@ -1,14 +1,8 @@ """Grouped physical main/gas/LDA owners, retaining native common health.""" -import unittest from opendbc.safety.tests import test_hyundai_kona_lda_aol as kona -class TestHyundaiGroupedNonSccAol(unittest.TestCase): - setUp = kona.TestHyundaiKonaLdaAol.setUp - tearDown = kona.TestHyundaiKonaLdaAol.tearDown - reset = kona.TestHyundaiKonaLdaAol.reset - rx = kona.TestHyundaiKonaLdaAol.rx - request = kona.TestHyundaiKonaLdaAol.request +class TestHyundaiGroupedNonSccAol(kona.KonaAolFixture): def grouped_feed(self, word, main=False, source=None, pressed=False, engagement_source=True): self.safety.set_timer(self.now) count = self.counter diff --git a/opendbc_repo/opendbc/safety/tests/test_hyundai_main_rearm.py b/opendbc_repo/opendbc/safety/tests/test_hyundai_main_rearm.py index 6d972f6c74..1a19ce35e1 100644 --- a/opendbc_repo/opendbc/safety/tests/test_hyundai_main_rearm.py +++ b/opendbc_repo/opendbc/safety/tests/test_hyundai_main_rearm.py @@ -1,5 +1,3 @@ -import unittest - import pytest from opendbc.can import CANPacker @@ -8,12 +6,6 @@ from opendbc.safety.tests.libsafety import libsafety_py from opendbc.safety.tests import test_hyundai_classic_long_aol as classic_fixture -class _ClassicSources(unittest.TestCase): - setUp = classic_fixture.TestHyundaiClassicLongAol.setUp - feed = classic_fixture.TestHyundaiClassicLongAol.feed - rx = classic_fixture.TestHyundaiClassicLongAol.rx - - class Sources: def __init__(self, profile): self.profile = profile @@ -22,7 +14,7 @@ class Sources: self.counter = 0 self.next_health_tick = 1_000_000 if profile == 'elantra': - self.classic = _ClassicSources(methodName='runTest') + self.classic = classic_fixture.ClassicLongAolFixture(methodName='runTest') self.classic.setUp() word, model = 0x800E, CarParams.SafetyModel.hyundai self.packer = self.classic.packer diff --git a/opendbc_repo/opendbc/safety/tests/test_nexo_stock_aol.py b/opendbc_repo/opendbc/safety/tests/test_nexo_stock_aol.py index cc14e8c92f..5ea74911f1 100644 --- a/opendbc_repo/opendbc/safety/tests/test_nexo_stock_aol.py +++ b/opendbc_repo/opendbc/safety/tests/test_nexo_stock_aol.py @@ -1,16 +1,10 @@ -import unittest from opendbc.car.structs import CarParams +from opendbc.safety.tests import test_hyundai_kona_lda_aol as kona from opendbc.safety.tests.test_hyundai_classic_scc_aol import TestHyundaiClassicSccAol as Shared -class TestNexoStockAol(unittest.TestCase): - setUp = Shared.setUp - tearDown = Shared.tearDown - reset = Shared.reset - rx = Shared.rx - request = Shared.request - +class TestNexoStockAol(kona.KonaAolFixture): def feed(self, word, *, gas=0, gas_bus=0, omit=False, pressed=False): Shared.feed(self, word, main=True, source='BCM_PO_11', pressed=pressed) if not omit: diff --git a/prebuilt.json b/prebuilt.json index ee7370fb72..2ac6c2de87 100644 --- a/prebuilt.json +++ b/prebuilt.json @@ -1 +1 @@ -{"protected_inventory_sha256": "c13882ca787971dd7680c91b45c4638f0ce20bbf727ce81c9c85a9faeb567969", "schema_version": 1} +{"protected_inventory_sha256": "e2a86d07b2fbe2cc22601c17cc04f930a698bec511846f2996525f63c417ac9e", "schema_version": 1}