diff --git a/tests/interfaces/__init__.py b/tests/interfaces/__init__.py index fa6ad34f6..0b5157b46 100644 --- a/tests/interfaces/__init__.py +++ b/tests/interfaces/__init__.py @@ -7,3 +7,7 @@ sip.setapi(u'QTime', 2) sip.setapi(u'QUrl', 2) sip.setapi(u'QVariant', 2) +from PyQt4 import QtGui + +# Only one QApplication can be created. Use QtGui.QApplication.instance() when you need to "create" a QApplication. +application = QtGui.QApplication([]) diff --git a/tests/interfaces/openlp_core_lib/test_pluginmanager.py b/tests/interfaces/openlp_core_lib/test_pluginmanager.py index f0aac5113..89dcdac0d 100644 --- a/tests/interfaces/openlp_core_lib/test_pluginmanager.py +++ b/tests/interfaces/openlp_core_lib/test_pluginmanager.py @@ -26,7 +26,7 @@ class TestPluginManager(TestCase): Settings().set_filename(self.ini_file) Registry.create() Registry().register(u'service_list', MagicMock()) - self.app = QtGui.QApplication([]) + self.app = QtGui.QApplication.instance() self.main_window = QtGui.QMainWindow() Registry().register(u'main_window', self.main_window) self.plugins_dir = os.path.abspath(os.path.join(os.path.basename(__file__), u'..', u'openlp', u'plugins')) diff --git a/tests/interfaces/openlp_core_ui/test_filerenamedialog.py b/tests/interfaces/openlp_core_ui/test_filerenamedialog.py index 26c07a514..61d2da75b 100644 --- a/tests/interfaces/openlp_core_ui/test_filerenamedialog.py +++ b/tests/interfaces/openlp_core_ui/test_filerenamedialog.py @@ -15,7 +15,7 @@ class TestStartFileRenameForm(TestCase): Create the UI """ Registry.create() - self.app = QtGui.QApplication([]) + self.app = QtGui.QApplication.instance() self.main_window = QtGui.QMainWindow() Registry().register(u'main_window', self.main_window) self.form = filerenameform.FileRenameForm() diff --git a/tests/interfaces/openlp_core_ui/test_servicemanager.py b/tests/interfaces/openlp_core_ui/test_servicemanager.py index bb62bd6e6..db161022b 100644 --- a/tests/interfaces/openlp_core_ui/test_servicemanager.py +++ b/tests/interfaces/openlp_core_ui/test_servicemanager.py @@ -3,7 +3,7 @@ """ from unittest import TestCase -from mock import MagicMock +from mock import MagicMock, patch from PyQt4 import QtGui @@ -11,17 +11,18 @@ from openlp.core.lib import Registry, ScreenList from openlp.core.ui.mainwindow import MainWindow -class TestStartNoteDialog(TestCase): +class TestServiceManager(TestCase): def setUp(self): """ Create the UI """ Registry.create() - self.app = QtGui.QApplication([]) + self.app = QtGui.QApplication.instance() ScreenList.create(self.app.desktop()) Registry().register(u'application', MagicMock()) - self.main_window = MainWindow() + with patch(u'openlp.core.lib.PluginManager'): + self.main_window = MainWindow() self.service_manager = Registry().get(u'service_manager') def tearDown(self): diff --git a/tests/interfaces/openlp_core_ui/test_servicenotedialog.py b/tests/interfaces/openlp_core_ui/test_servicenotedialog.py index 54560f224..e04f9975d 100644 --- a/tests/interfaces/openlp_core_ui/test_servicenotedialog.py +++ b/tests/interfaces/openlp_core_ui/test_servicenotedialog.py @@ -17,7 +17,7 @@ class TestStartNoteDialog(TestCase): Create the UI """ Registry.create() - self.app = QtGui.QApplication([]) + self.app = QtGui.QApplication.instance() self.main_window = QtGui.QMainWindow() Registry().register(u'main_window', self.main_window) self.form = servicenoteform.ServiceNoteForm() diff --git a/tests/interfaces/openlp_core_ui/test_starttimedialog.py b/tests/interfaces/openlp_core_ui/test_starttimedialog.py index d4b9e4fb9..c09426a1f 100644 --- a/tests/interfaces/openlp_core_ui/test_starttimedialog.py +++ b/tests/interfaces/openlp_core_ui/test_starttimedialog.py @@ -17,7 +17,7 @@ class TestStartTimeDialog(TestCase): Create the UI """ Registry.create() - self.app = QtGui.QApplication([]) + self.app = QtGui.QApplication.instance() self.main_window = QtGui.QMainWindow() Registry().register(u'main_window', self.main_window) self.form = starttimeform.StartTimeForm()