From bbd60532e51ca851a1c806ca34625cc29a1fdfbb Mon Sep 17 00:00:00 2001 From: Sam Tygier Date: Wed, 3 Jul 2024 18:15:39 +0100 Subject: [PATCH 1/2] Catch errors raised by operations in the system tests With a filter for messages that are expected * Crop coordinates after crop is applied * Flat fielding causes negatives with test data --- .../gui/test/gui_system_operations_test.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/mantidimaging/gui/test/gui_system_operations_test.py b/mantidimaging/gui/test/gui_system_operations_test.py index 4d863650893..80403dc6a89 100644 --- a/mantidimaging/gui/test/gui_system_operations_test.py +++ b/mantidimaging/gui/test/gui_system_operations_test.py @@ -46,6 +46,12 @@ ("Rotate Stack", []), ] +ALLOWED_ERRORS = [ + 'Negative values found in result preview for slice 0.', + 'Flat-fielding completed. Slices containing negative values in IMAT_Flower_Tomo_000000: all slices.', + 'Error applying filter for preview: could not broadcast input array from shape (1,80,80) into shape (1,90,90)' +] + @start_multiprocessing_pool class TestGuiSystemOperations(GuiSystemBase): @@ -96,7 +102,8 @@ def _get_operation_button_widget(form: QFormLayout, button_name: str) -> QWidget raise ValueError(f"Could not find '{button_name}' in form") @parameterized.expand(OP_LIST) - def test_run_operation_stack(self, op_name, params): + @mock.patch("mantidimaging.gui.windows.operations.FiltersWindowView.show_error_dialog") + def test_run_operation_stack(self, op_name, params, mock_error_dialog): QTest.qWait(SHOW_DELAY) index = self.op_window.filterSelector.findText(op_name) self.assertGreaterEqual(index, 0, f'Operation "{op_name}" not found in filterSelector') @@ -115,6 +122,12 @@ def test_run_operation_stack(self, op_name, params): QTest.qWait(SHORT_DELAY) wait_until(lambda: self.op_window.presenter.filter_is_running is False, max_retry=600) + caught_errors = mock_error_dialog.call_args_list + for caught_args in caught_errors: + caught_error = caught_args[0][0] + if caught_error not in ALLOWED_ERRORS: + raise AssertionError(f"Operation gave error: {caught_error}") + @parameterized.expand(product(OP_LIST[:3], ["new", "original"])) def test_run_operation_stack_safe(self, op_info, keep_stack): op_name, params = op_info From 68cd1a607cad4a4a3581fa6ef5586de294cbecaa Mon Sep 17 00:00:00 2001 From: Sam Tygier Date: Thu, 4 Jul 2024 09:20:39 +0100 Subject: [PATCH 2/2] Release notes --- docs/release_notes/next/dev-2250-catch-operations-errors | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 docs/release_notes/next/dev-2250-catch-operations-errors diff --git a/docs/release_notes/next/dev-2250-catch-operations-errors b/docs/release_notes/next/dev-2250-catch-operations-errors new file mode 100644 index 00000000000..4b0a8419fc8 --- /dev/null +++ b/docs/release_notes/next/dev-2250-catch-operations-errors @@ -0,0 +1,2 @@ +#2250 : Make systems tests stricter to catch operations errors +