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
1 changed files with 6 additions and 1 deletions

View File

@ -43,7 +43,12 @@ from openlp.core.common.settings import Settings
@pytest.fixture
def qapp(qtbot):
"""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()
yield app
del app