File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1313import scipy
1414import tifffile
1515from guidata .env import execenv
16+ from qtpy import QtCore as QC
17+ from qtpy import QtWidgets as QW
1618
1719import plotpy
1820
@@ -49,6 +51,20 @@ def pytest_runtest_setup(item):
4951 pytest .skip ("Skipped in offscreen mode (requires display)" )
5052
5153
54+ @pytest .hookimpl (tryfirst = True )
55+ def pytest_runtest_teardown (item , nextitem ): # pylint: disable=unused-argument
56+ """Run teardown after each test."""
57+ # This is necessary to close any open dialogs after each test because the
58+ # mechanism used to close them automatically in the test suite
59+ # (i.e., `exec_dialog`) does not work with some PyQt versions.
60+ QC .QCoreApplication .processEvents ()
61+ qapp : QW .QApplication = QW .QApplication .instance ()
62+ if qapp is not None :
63+ for widget in qapp .topLevelWidgets ():
64+ if isinstance (widget , QW .QDialog ) and widget .isVisible ():
65+ widget .reject ()
66+
67+
5268@pytest .fixture (scope = "session" , autouse = True )
5369def disable_gc_for_tests ():
5470 """Disable garbage collection for all tests in the session."""
You can’t perform that action at this time.
0 commit comments