diff --git a/docs/release_notes/next/fix-2309-spectrum-widget-test-fix b/docs/release_notes/next/fix-2309-spectrum-widget-test-fix new file mode 100644 index 00000000000..8a0374a2dcd --- /dev/null +++ b/docs/release_notes/next/fix-2309-spectrum-widget-test-fix @@ -0,0 +1 @@ +#2309: Fix SpectrumWidgetTest warnings diff --git a/mantidimaging/gui/windows/spectrum_viewer/spectrum_widget.py b/mantidimaging/gui/windows/spectrum_viewer/spectrum_widget.py index a2f6982e6d1..227bfac29bd 100644 --- a/mantidimaging/gui/windows/spectrum_viewer/spectrum_widget.py +++ b/mantidimaging/gui/windows/spectrum_viewer/spectrum_widget.py @@ -348,13 +348,12 @@ def set_tof_axis_label(self, tof_axis_label: str) -> None: class SpectrumProjectionWidget(GraphicsLayoutWidget): image: MIMiniImageView - def __init__(self, parent: MainWindowView) -> None: - super().__init__(parent) - self._main_window = parent + def __init__(self, main_window: MainWindowView) -> None: + super().__init__() self.image = MIMiniImageView(name="Projection", view_box_type=CustomViewBox) self.addItem(self.image, 0, 0) self.ci.layout.setRowStretchFactor(0, 3) - nan_check_menu = [("Crop Coordinates", lambda: self._main_window.presenter.show_operation("Crop Coordinates")), - ("NaN Removal", lambda: self._main_window.presenter.show_operation("NaN Removal"))] + nan_check_menu = [("Crop Coordinates", lambda: main_window.presenter.show_operation("Crop Coordinates")), + ("NaN Removal", lambda: main_window.presenter.show_operation("NaN Removal"))] self.image.enable_nan_check(actions=nan_check_menu) diff --git a/mantidimaging/gui/windows/spectrum_viewer/test/spectrum_test.py b/mantidimaging/gui/windows/spectrum_viewer/test/spectrum_test.py index b29015b714a..65b3add07a9 100644 --- a/mantidimaging/gui/windows/spectrum_viewer/test/spectrum_test.py +++ b/mantidimaging/gui/windows/spectrum_viewer/test/spectrum_test.py @@ -48,8 +48,7 @@ def test_WHEN_colour_is_not_valid_THEN_roi_colour_is_unchanged(self): class SpectrumWidgetTest(unittest.TestCase): def setUp(self) -> None: - with mock.patch("mantidimaging.gui.windows.main.view.WelcomeScreenPresenter"): - self.main_window = MainWindowView() + self.main_window = mock.create_autospec(MainWindowView) self.view = mock.create_autospec(SpectrumViewerWindowView) self.view.current_dataset_id = uuid.uuid4() self.view.parent = mock.create_autospec(SpectrumViewerWindowPresenter)