From 33a8a767f31a57bcfda624d503ed39e0e4578dcb Mon Sep 17 00:00:00 2001 From: wakonig_k Date: Tue, 15 Apr 2025 12:08:06 +0200 Subject: [PATCH] test(launch_window): add test for launching UI file that raises ValueError for QMainWindow --- tests/unit_tests/test_launch_window.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/unit_tests/test_launch_window.py b/tests/unit_tests/test_launch_window.py index 0b997aba..b7e19fe7 100644 --- a/tests/unit_tests/test_launch_window.py +++ b/tests/unit_tests/test_launch_window.py @@ -46,3 +46,15 @@ def test_launch_window_launch_ui_file(bec_launch_window): # In real usage, the GUIServer would handle this in the sigint handler in case of a ctrl-c initiated shutdown. res.close() res.deleteLater() + + +def test_launch_window_launch_ui_file_raises_for_qmainwindow(bec_launch_window): + # Mock the file dialog to return a specific UI file path + # the selected file must contain a QMainWindow widget but can be any file + ui_file_path = os.path.join(base_path, "applications/alignment/alignment_1d/alignment_1d.ui") + + # Call the method to launch the custom UI file + with pytest.raises(ValueError) as excinfo: + bec_launch_window.launch("custom_ui_file", ui_file=ui_file_path) + + assert "Loading a QMainWindow from a UI file is currently not supported." in str(excinfo.value)