0
0
mirror of https://github.com/bec-project/bec_widgets.git synced 2025-07-14 11:41:49 +02:00

refactor(tests): positioner box test changed to use create_widget fixture

This commit is contained in:
2024-09-03 13:33:14 +02:00
parent 18d8561c96
commit df5eff3147
2 changed files with 2 additions and 4 deletions

View File

@ -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 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. should be used in all tests that require a widget to be created.
DO NOT CREATE WIDGETS DIRECTLY IN A FIXTURE!
Args: Args:
qtbot (fixture): pytest-qt fixture qtbot (fixture): pytest-qt fixture
@ -58,7 +57,6 @@ def create_widget(qtbot, widget, *args, **kwargs):
Returns: Returns:
QWidget: the created widget QWidget: the created widget
""" """
widget = widget(*args, **kwargs) widget = widget(*args, **kwargs)
qtbot.addWidget(widget) qtbot.addWidget(widget)

View File

@ -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 bec_widgets.widgets.positioner_box.positioner_control_line import PositionerControlLine
from .client_mocks import mocked_client from .client_mocks import mocked_client
from .conftest import create_widget
@pytest.fixture @pytest.fixture
@ -24,8 +25,7 @@ def positioner_box(qtbot, mocked_client):
"bec_widgets.widgets.positioner_box.positioner_box.PositionerBox._check_device_is_valid", "bec_widgets.widgets.positioner_box.positioner_box.PositionerBox._check_device_is_valid",
return_value=True, return_value=True,
): ):
db = PositionerBox(device="samx", client=mocked_client) db = create_widget(qtbot, PositionerBox, device="samx", client=mocked_client)
qtbot.addWidget(db)
yield db yield db