Fix tests (broken on newer versions of pytest-qt)

This commit is contained in:
Daniel Martin 2021-06-18 05:19:44 +00:00 committed by Raoul Snyman
parent 0fffbb2f17
commit 00d5570d1d

View File

@ -43,7 +43,12 @@ from openlp.core.common.settings import Settings
@pytest.fixture @pytest.fixture
def qapp(qtbot): def qapp(qtbot):
"""An instance of QApplication""" """An instance of QApplication"""
qt_api.QApplication.instance() # Newer versions of pytest-qt have QApplication in the widgets module.
# Catch attribute error if the widgets module is missing and instantiate QApplication the old way.
try:
qt_api.QtWidgets.QApplication.instance()
except AttributeError:
qt_api.QApplication.instance()
app = OpenLP() app = OpenLP()
yield app yield app
del app del app