From e31b0e9a6f7bd8adb0ce60e1cfe4b8eefecbe2d2 Mon Sep 17 00:00:00 2001 From: Dawn Date: Wed, 16 Sep 2026 11:53:49 +0200 Subject: [PATCH] fix: cast the mocked daq.unmount for basedpyright on CI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CI's basedpyright (latest from the index, newer than the local venv) types win.daq as the real DAQWorker, so assert_not_called on the patched-in MagicMock flagged the two new gate-test lines. Note: the pytest job segfaults are NOT from this branch — plain origin/main crashes 2/4 runs under PySide6 6.11.2 (what CI installs; uv.lock pins 6.9.0 which is stable). Needs a separate dependency fix. Co-Authored-By: Claude Fable 5 --- tests/unit/gui/test_main_window.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/unit/gui/test_main_window.py b/tests/unit/gui/test_main_window.py index 6a901043..8e79c9be 100644 --- a/tests/unit/gui/test_main_window.py +++ b/tests/unit/gui/test_main_window.py @@ -1,3 +1,4 @@ +from typing import cast from unittest.mock import MagicMock, patch import pytest @@ -105,16 +106,18 @@ def test_main_window_init(qtbot, mock_ui_state, daq_status_factory): == "Manual collection stopped: detector error." ) - # Manual unmount respects the hutch PSS gate. + # Manual unmount respects the hutch PSS gate. cast: win.daq is a + # patched-in MagicMock, but pyright sees the real DAQWorker type. + unmount_mock = cast(MagicMock, win.daq.unmount) with ( patch.object(win, "_hutch_blocks_mount", return_value="hutch open"), patch("aare.gui.main_window.QMessageBox"), ): win._on_manual_unmount_requested() - win.daq.unmount.assert_not_called() + unmount_mock.assert_not_called() with patch.object(win, "_hutch_blocks_mount", return_value=None): win._on_manual_unmount_requested() - win.daq.unmount.assert_called_once() + unmount_mock.assert_called_once() # Motion watch: only the robot station switches to the combined # beamline view. Moving no longer does (users kept losing the sample