From cfe7f009e255333a75ee99cf204ba8dd4fa1543f Mon Sep 17 00:00:00 2001 From: Dom <168790843+firestar5683@users.noreply.github.com> Date: Wed, 18 Nov 2026 16:46:30 -0600 Subject: [PATCH] Clarify regression-test types without changing runtime behavior --- .../conditional_mode/tests/test_launch_geometry.py | 2 +- .../starpilot/longitudinal/tests/test_highlander_cruise.py | 4 +++- .../starpilot/longitudinal/tests/test_lead_takeoff.py | 4 ++-- .../ui/tests/test_actuation_recovery_callbacks.py | 7 ++++--- openpilot/starpilot/ui/tests/test_cem_passive_scene.py | 5 ++++- .../starpilot/ui/tests/test_updater_error_visibility.py | 4 ++-- 6 files changed, 16 insertions(+), 10 deletions(-) diff --git a/openpilot/starpilot/conditional_mode/tests/test_launch_geometry.py b/openpilot/starpilot/conditional_mode/tests/test_launch_geometry.py index 3c6fd06f9b..9f79004ecc 100644 --- a/openpilot/starpilot/conditional_mode/tests/test_launch_geometry.py +++ b/openpilot/starpilot/conditional_mode/tests/test_launch_geometry.py @@ -46,7 +46,7 @@ class RecordedLaunchTests(CemGreenCallerTests): if release is not None: self.assertFalse(held or plan.shouldStop) self.assertGreater(plan.aTarget, 0.0) - self.assertIsNotNone(release) + assert release is not None self.assertLess(release, 5953.0) def test_candidate_frame_rejects_red_lead_and_lost_authority(self): diff --git a/openpilot/starpilot/longitudinal/tests/test_highlander_cruise.py b/openpilot/starpilot/longitudinal/tests/test_highlander_cruise.py index aa71f1f068..81a629c1fb 100644 --- a/openpilot/starpilot/longitudinal/tests/test_highlander_cruise.py +++ b/openpilot/starpilot/longitudinal/tests/test_highlander_cruise.py @@ -137,7 +137,9 @@ def test_cruise_solver_keeps_saved_jerk_factors_and_primary_solver_state(): before = (owner.mpc.params.copy(), owner.mpc.a_prev.copy(), owner.mpc._cached_cost_weights) native_before = np.array([owner.mpc.solver.get(i, 'x') for i in range(len(owner.mpc.params))]) primary = owner.mpc._cached_cost_weights - assert native._cached_cost_weights[0][4] < primary[0][4] + native_weights = native._cached_cost_weights + assert native_weights is not None and primary is not None + assert native_weights[0][4] < primary[0][4] sm, now = frame(4, setting=86.) owner.button_cruise.sample(sm, now_ns=now, drive_id=DRIVE, target_speed=86./3.6, brake_floor=-.3, speed=25., previous_accel=owner.output_a_target, reference=owner.mpc, blocked=False) diff --git a/openpilot/starpilot/longitudinal/tests/test_lead_takeoff.py b/openpilot/starpilot/longitudinal/tests/test_lead_takeoff.py index 4b4de823e0..81130a258c 100644 --- a/openpilot/starpilot/longitudinal/tests/test_lead_takeoff.py +++ b/openpilot/starpilot/longitudinal/tests/test_lead_takeoff.py @@ -306,7 +306,7 @@ def test_every_other_registered_platform_retains_maximum_breakaway(): @pytest.mark.parametrize('cap', [None, .2, 1.2, 2.]) -def test_gas_highlander_actual_factory_planner_keeps_confirmed_departure_floor(cap): +def test_gas_highlander_actual_factory_planner_keeps_confirmed_departure_floor(cap, monkeypatch): from opendbc.car.toyota.interface import CarInterface from opendbc.car.toyota.values import CAR from openpilot.selfdrive.controls.lib.longitudinal_planner import LongitudinalPlanner @@ -321,7 +321,7 @@ def test_gas_highlander_actual_factory_planner_keeps_confirmed_departure_floor(c result = step(enabled, projected, target, should_stop) calls.append((projected, target, result)) return result - owner.lead_takeoff.step = record_step + monkeypatch.setattr(owner.lead_takeoff, "step", record_step) for tick in range(12): now = NOW + tick * 50_000_000 sm = NativeFrame() diff --git a/openpilot/starpilot/ui/tests/test_actuation_recovery_callbacks.py b/openpilot/starpilot/ui/tests/test_actuation_recovery_callbacks.py index f30eb97a85..dd7178b271 100644 --- a/openpilot/starpilot/ui/tests/test_actuation_recovery_callbacks.py +++ b/openpilot/starpilot/ui/tests/test_actuation_recovery_callbacks.py @@ -2,6 +2,7 @@ import ast from pathlib import Path from types import SimpleNamespace as NS +from typing import Any from unittest.mock import Mock from openpilot.starpilot.ui.actuation_recovery import acknowledge, KEY @@ -30,7 +31,7 @@ def setup(): def test_mici_alert_wires_explicit_slide_and_rechecks_at_confirmation(): params, physical = setup() - env = {'KEY': KEY, 'acknowledge': acknowledge, 'tr': lambda s: s, 'gui_app': Mock(), + env: dict[str, Any] = {'KEY': KEY, 'acknowledge': acknowledge, 'tr': lambda s: s, 'gui_app': Mock(), 'BigConfirmationDialog': Mock(), 'BigDialog': Mock()} methods('selfdrive/ui/mici/layouts/offroad_alerts.py', 'MiciOffroadAlerts', ['_acknowledge_actuation'], env) obj = NS(params=params, _actuation_physical=physical) @@ -46,7 +47,7 @@ def test_mici_alert_wires_explicit_slide_and_rechecks_at_confirmation(): def test_mici_build_registers_only_actuation_and_update_callbacks(): - env = {'KEY': KEY, 'AlertData': lambda **k: NS(**k), 'AlertItem': Mock(side_effect=lambda _: Mock()), + env: dict[str, Any] = {'KEY': KEY, 'AlertData': lambda **k: NS(**k), 'AlertItem': Mock(side_effect=lambda _: Mock()), 'OFFROAD_ALERTS': {KEY: {'severity': 1}, 'Other': {'severity': 0}}, 'HARDWARE': Mock()} methods('selfdrive/ui/mici/layouts/offroad_alerts.py', 'MiciOffroadAlerts', ['_build_alerts'], env) obj = NS(alert_items=[], _scroller=Mock(), _acknowledge_actuation=Mock()) @@ -61,7 +62,7 @@ def test_large_confirmation_cancel_and_mode_change_do_not_clear(): path = ROOT / 'selfdrive/ui/widgets/offroad_alerts.py' tree = ast.parse(path.read_text()) callback = next(n for n in ast.walk(tree) if isinstance(n, ast.FunctionDef) and n.name == 'excessive_actuation_callback') - env = {'self': NS(params=params, _actuation_physical=physical, dismiss_callback=Mock()), + env: dict[str, Any] = {'self': NS(params=params, _actuation_physical=physical, dismiss_callback=Mock()), 'KEY': KEY, 'acknowledge': acknowledge, 'DialogResult': NS(CONFIRM=1, CANCEL=0), 'tr': lambda s: s, 'gui_app': Mock(), 'ConfirmDialog': Mock(), 'alert_dialog': Mock()} exec(compile(ast.Module(body=[callback], type_ignores=[]), str(path), 'exec'), env) diff --git a/openpilot/starpilot/ui/tests/test_cem_passive_scene.py b/openpilot/starpilot/ui/tests/test_cem_passive_scene.py index 7214dd3a33..5167f85170 100644 --- a/openpilot/starpilot/ui/tests/test_cem_passive_scene.py +++ b/openpilot/starpilot/ui/tests/test_cem_passive_scene.py @@ -64,4 +64,7 @@ def test_real_passive_scene_survives_control_reset(aol, lead_present): assert data.indicator_type is IndicatorType.STOP_LIGHT else: assert data is None - assert ConditionalPerceptionProjector().project(received.slcState, **(args | {'now_ns': stamp+250_000_000})) is None + assert ConditionalPerceptionProjector().project( + received.slcState, now_ns=stamp+250_000_000, event_ns=stamp+1_000_000, drive_id=MONO, choice=ModeChoice.CEM, + lateral_active=True, selfdrive_enabled=not aol, car_valid=True, system_long=True, + ) is None diff --git a/openpilot/starpilot/ui/tests/test_updater_error_visibility.py b/openpilot/starpilot/ui/tests/test_updater_error_visibility.py index 109c1d6fac..da2e4a0a85 100644 --- a/openpilot/starpilot/ui/tests/test_updater_error_visibility.py +++ b/openpilot/starpilot/ui/tests/test_updater_error_visibility.py @@ -27,7 +27,7 @@ def test_native_error_log_prefers_bounded_plain_updater_error(error): with (patch.object(software, "ui_state", NS(params=NS(get=lambda key: error))), patch.object(software, "gui_app") as app, patch.object(software, "ConfirmDialog") as dialog, patch.object(software.Path, "read_text", side_effect=AssertionError("must not read crash log"))): - software.SoftwareLayout._on_error_log(None) + software.SoftwareLayout._on_error_log(software.SoftwareLayout.__new__(software.SoftwareLayout)) assert dialog.call_args.args[0] == expected[:4096] assert dialog.call_args.kwargs["rich"] is False app.push_widget.assert_called_once() @@ -38,6 +38,6 @@ def test_native_error_log_preserves_crash_log_fallback(): with (patch.object(software, "ui_state", NS(params=NS(get=lambda key: None))), patch.object(software, "gui_app"), patch.object(software, "ConfirmDialog") as dialog, patch.object(software.Path, "read_text", return_value="Existing crash log")): - software.SoftwareLayout._on_error_log(None) + software.SoftwareLayout._on_error_log(software.SoftwareLayout.__new__(software.SoftwareLayout)) assert dialog.call_args.args[0] == "Existing crash log" assert dialog.call_args.kwargs["rich"] is True