From ba9fbd52d725bc3f756bc82cdcb0d789a3e35d53 Mon Sep 17 00:00:00 2001 From: DevTekVE Date: Sat, 11 Jan 2025 21:42:06 +0100 Subject: [PATCH] Refactor test_dynamic_controller and fix formatting issues Added a new import for STOP_AND_GO_FRAME and corrected a float initialization for v_ego in MockCarState. Also fixed indentation in the test_standstill_detection method for consistency. --- .../selfdrive/controls/lib/tests/test_dynamic_controller.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sunnypilot/selfdrive/controls/lib/tests/test_dynamic_controller.py b/sunnypilot/selfdrive/controls/lib/tests/test_dynamic_controller.py index 4ea956dcc7..077071f82f 100644 --- a/sunnypilot/selfdrive/controls/lib/tests/test_dynamic_controller.py +++ b/sunnypilot/selfdrive/controls/lib/tests/test_dynamic_controller.py @@ -8,7 +8,7 @@ from sunnypilot.selfdrive.controls.lib.dynamic_experimental_controller import ( SNG_State, SLOWNESS_CRUISE_OFFSET, SLOW_DOWN_BP, - SLOW_DOWN_DIST + SLOW_DOWN_DIST, STOP_AND_GO_FRAME ) import unittest @@ -20,7 +20,7 @@ class MockInterp: return np.interp(x, xp, fp) class MockCarState: - def __init__(self, v_ego=0, standstill=False, left_blinker=False, right_blinker=False): + def __init__(self, v_ego=0., standstill=False, left_blinker=False, right_blinker=False): self.vEgo = v_ego self.standstill = standstill self.leftBlinker = left_blinker @@ -65,7 +65,7 @@ class TestDynamicExperimentalController(unittest.TestCase): self.assertFalse(self.controller._has_dangerous_ttc) self.assertFalse(self.controller._has_mpc_fcw) - def test_standstill_detection(self): + def test_standstill_detection(self): """Test standstill detection and state transitions""" car_state = MockCarState(standstill=True) lead_one = MockLeadOne()