Skip to content

Commit

Permalink
Revert "Try if by any chance changing fixture order and lifetime help…
Browse files Browse the repository at this point in the history
…s w/ crashes"

This reverts commit 9ccafe0.
  • Loading branch information
lbianchi-lbl committed Jun 21, 2022
1 parent f0e7b7f commit c3b9e83
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions foqus_lib/gui/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ def qtbot_params(request):
}


@pytest.fixture(scope="class")
def qtbot(request, qapp, qtbot_params) -> pytest_qt_extras.QtBot:
if sys.version_info < (3, 7):
pytest.skip("GUI tests are not available for Python 3.6 or lower")
_qtbot = pytest_qt_extras.QtBot(request, **qtbot_params)
with capture_exceptions() as exceptions:
yield _qtbot
if exceptions:
pytest.fail(format_captured_exceptions(exceptions))
# _qtbot.cleanup()


@pytest.fixture(scope="session")
def main_window_params(request):
cfg = request.config
Expand All @@ -48,8 +60,8 @@ def main_window_params(request):
}


@pytest.fixture(scope="module")
def main_window(foqus_session, main_window_params):
@pytest.yield_fixture(scope="class")
def main_window(foqus_session, qtbot, main_window_params):
from foqus_lib import foqus

foqus.guiImport(mpl_backend="AGG")
Expand All @@ -73,6 +85,7 @@ def main_window(foqus_session, main_window_params):
main_win.app = QtWidgets.QApplication.instance()
print(f"main_win.app={main_win.app}")
# qtbot.add_widget(main_win)
qtbot.waitForWindowShown(main_win)
print(f"main_win.app.activeWindow()={main_win.app.activeWindow()}")
yield main_win

Expand All @@ -83,25 +96,11 @@ def handle_closing_prompt(w: QtWidgets.QMessageBox):
handle_closing_prompt
):
main_win.close()
QtWidgets.QApplication.processEvents()


@pytest.fixture(scope="class")
def qtbot(request, qapp, qtbot_params, main_window) -> pytest_qt_extras.QtBot:
if sys.version_info < (3, 7):
pytest.skip("GUI tests are not available for Python 3.6 or lower")
_qtbot = pytest_qt_extras.QtBot(request, **qtbot_params)
_qtbot.waitForWindowShown(main_window)
with capture_exceptions() as exceptions:
yield _qtbot
if exceptions:
pytest.fail(format_captured_exceptions(exceptions))
_qtbot.cleanup()
QtWidgets.QApplication.processEvents()
qtbot.cleanup()


@pytest.fixture(scope="class")
def uq_setup_view(main_window, flowsheet_session_file):
def uq_setup_view(main_window, flowsheet_session_file, qtbot):
main_window.loadSessionFile(flowsheet_session_file, saveCurrent=False)
main_window.uqSetupAction.trigger()
return main_window.uqSetupFrame

0 comments on commit c3b9e83

Please sign in to comment.