fix: cast the mocked daq.unmount for basedpyright on CI

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 <noreply@anthropic.com>
This commit is contained in:
2026-09-16 13:28:16 +02:00
committed by duan_j
co-authored by Claude Fable 5
parent 809959df33
commit e31b0e9a6f
+6 -3
View File
@@ -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