From df5eff3147c79ff0278e6a5a09c8f73d5236aed3 Mon Sep 17 00:00:00 2001 From: wyzula-jan Date: Tue, 3 Sep 2024 13:33:14 +0200 Subject: [PATCH] refactor(tests): positioner box test changed to use create_widget fixture --- tests/unit_tests/conftest.py | 2 -- tests/unit_tests/test_positioner_box.py | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/unit_tests/conftest.py b/tests/unit_tests/conftest.py index e91b90f6..771c9892 100644 --- a/tests/unit_tests/conftest.py +++ b/tests/unit_tests/conftest.py @@ -48,7 +48,6 @@ def create_widget(qtbot, widget, *args, **kwargs): """ Create a widget and add it to the qtbot for testing. This is a helper function that should be used in all tests that require a widget to be created. - DO NOT CREATE WIDGETS DIRECTLY IN A FIXTURE! Args: qtbot (fixture): pytest-qt fixture @@ -58,7 +57,6 @@ def create_widget(qtbot, widget, *args, **kwargs): Returns: QWidget: the created widget - """ widget = widget(*args, **kwargs) qtbot.addWidget(widget) diff --git a/tests/unit_tests/test_positioner_box.py b/tests/unit_tests/test_positioner_box.py index 78a5e546..a9d07c9f 100644 --- a/tests/unit_tests/test_positioner_box.py +++ b/tests/unit_tests/test_positioner_box.py @@ -13,6 +13,7 @@ from bec_widgets.widgets.positioner_box.positioner_box import PositionerBox from bec_widgets.widgets.positioner_box.positioner_control_line import PositionerControlLine from .client_mocks import mocked_client +from .conftest import create_widget @pytest.fixture @@ -24,8 +25,7 @@ def positioner_box(qtbot, mocked_client): "bec_widgets.widgets.positioner_box.positioner_box.PositionerBox._check_device_is_valid", return_value=True, ): - db = PositionerBox(device="samx", client=mocked_client) - qtbot.addWidget(db) + db = create_widget(qtbot, PositionerBox, device="samx", client=mocked_client) yield db