Skip to content

Commit

Permalink
add teardown to metawidget fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
niksirbi committed Mar 17, 2024
1 parent 983a99b commit 242a92a
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions tests/test_unit/test_napari_widgets.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
import pytest
from qtpy.QtWidgets import QWidget
from qtpy.QtWidgets import QApplication, QWidget

from movement.napari.meta_widget import MovementMetaWidget


@pytest.fixture
def meta_widget(make_napari_viewer) -> MovementMetaWidget:
def meta_widget(make_napari_viewer, request) -> MovementMetaWidget:
"""Fixture to expose the MovementMetaWidget for testing.
Simultaneously acts as a smoke test that the widget
can be instantiated without crashing."""
can be instantiated without crashing. Also ensures
that the widget is properly closed after tests."""
viewer = make_napari_viewer()
return MovementMetaWidget(viewer)
widget = MovementMetaWidget(viewer)

def teardown():
widget.close() # Ensure the widget is closed after tests
QApplication.processEvents() # Process remaining events

request.addfinalizer(teardown) # Register the teardown function
return widget


@pytest.fixture
Expand Down

0 comments on commit 242a92a

Please sign in to comment.