Merge trunk

This commit is contained in:
Jonathan Springer 2014-03-12 18:15:08 -04:00
commit af5e751d27
16 changed files with 89 additions and 44 deletions

View File

@ -426,9 +426,9 @@ def get_locale_key(string):
The corresponding string. The corresponding string.
""" """
string = string.lower() string = string.lower()
# For Python 3 on platforms other than Windows ICU is not necessary. In those cases locale.strxfrm(str) can be used. # ICU is the prefered way to handle locale sort key, we fallback to locale.strxfrm which will work in most cases.
if os.name == 'nt': global ICU_COLLATOR
global ICU_COLLATOR try:
if ICU_COLLATOR is None: if ICU_COLLATOR is None:
import icu import icu
from .languagemanager import LanguageManager from .languagemanager import LanguageManager
@ -436,8 +436,8 @@ def get_locale_key(string):
icu_locale = icu.Locale(language) icu_locale = icu.Locale(language)
ICU_COLLATOR = icu.Collator.createInstance(icu_locale) ICU_COLLATOR = icu.Collator.createInstance(icu_locale)
return ICU_COLLATOR.getSortKey(string) return ICU_COLLATOR.getSortKey(string)
return locale.strxfrm(string).encode() except:
return locale.strxfrm(string).encode()
def get_natural_key(string): def get_natural_key(string):
""" """

View File

@ -7,7 +7,7 @@ import shutil
from tempfile import mkstemp, mkdtemp from tempfile import mkstemp, mkdtemp
from unittest import TestCase from unittest import TestCase
from PyQt4 import QtGui from PyQt4 import QtGui, QtCore
from openlp.core.common import Registry, Settings from openlp.core.common import Registry, Settings
from openlp.core.lib.pluginmanager import PluginManager from openlp.core.lib.pluginmanager import PluginManager
@ -30,12 +30,15 @@ class TestPluginManager(TestCase):
Settings().setValue('advanced/data path', self.temp_dir) Settings().setValue('advanced/data path', self.temp_dir)
Registry.create() Registry.create()
Registry().register('service_list', MagicMock()) Registry().register('service_list', MagicMock())
self.app = QtGui.QApplication([]) old_app_instance = QtCore.QCoreApplication.instance()
if old_app_instance is None:
self.app = QtGui.QApplication([])
else:
self.app = old_app_instance
self.main_window = QtGui.QMainWindow() self.main_window = QtGui.QMainWindow()
Registry().register('main_window', self.main_window) Registry().register('main_window', self.main_window)
def tearDown(self): def tearDown(self):
del self.app
del self.main_window del self.main_window
Settings().remove('advanced/data path') Settings().remove('advanced/data path')
shutil.rmtree(self.temp_dir) shutil.rmtree(self.temp_dir)

View File

@ -3,7 +3,7 @@
""" """
from unittest import TestCase from unittest import TestCase
from PyQt4 import QtGui, QtTest from PyQt4 import QtCore, QtGui, QtTest
from openlp.core.common import Registry from openlp.core.common import Registry
from openlp.core.ui import filerenameform from openlp.core.ui import filerenameform
@ -17,7 +17,11 @@ class TestStartFileRenameForm(TestCase):
Create the UI Create the UI
""" """
Registry.create() Registry.create()
self.app = QtGui.QApplication([]) old_app_instance = QtCore.QCoreApplication.instance()
if old_app_instance is None:
self.app = QtGui.QApplication([])
else:
self.app = old_app_instance
self.main_window = QtGui.QMainWindow() self.main_window = QtGui.QMainWindow()
Registry().register('main_window', self.main_window) Registry().register('main_window', self.main_window)
self.form = filerenameform.FileRenameForm() self.form = filerenameform.FileRenameForm()
@ -28,7 +32,6 @@ class TestStartFileRenameForm(TestCase):
""" """
del self.form del self.form
del self.main_window del self.main_window
del self.app
def window_title_test(self): def window_title_test(self):
""" """

View File

@ -4,7 +4,7 @@
from unittest import TestCase from unittest import TestCase
from PyQt4 import QtGui from PyQt4 import QtGui, QtCore
from openlp.core.common import Registry from openlp.core.common import Registry
from openlp.core.lib import ServiceItem from openlp.core.lib import ServiceItem
@ -20,7 +20,11 @@ class TestListPreviewWidget(TestCase):
Create the UI. Create the UI.
""" """
Registry.create() Registry.create()
self.app = QtGui.QApplication([]) old_app_instance = QtCore.QCoreApplication.instance()
if old_app_instance is None:
self.app = QtGui.QApplication([])
else:
self.app = old_app_instance
self.main_window = QtGui.QMainWindow() self.main_window = QtGui.QMainWindow()
self.image = QtGui.QImage(1, 1, QtGui.QImage.Format_RGB32) self.image = QtGui.QImage(1, 1, QtGui.QImage.Format_RGB32)
self.image_manager = MagicMock() self.image_manager = MagicMock()
@ -34,7 +38,6 @@ class TestListPreviewWidget(TestCase):
""" """
del self.preview_widget del self.preview_widget
del self.main_window del self.main_window
del self.app
def initial_slide_count_test(self): def initial_slide_count_test(self):
""" """

View File

@ -3,7 +3,7 @@ Package to test the openlp.core.ui.mainwindow package.
""" """
from unittest import TestCase from unittest import TestCase
from PyQt4 import QtGui from PyQt4 import QtGui, QtCore
from openlp.core.common import Registry from openlp.core.common import Registry
from openlp.core.ui.mainwindow import MainWindow from openlp.core.ui.mainwindow import MainWindow
@ -18,7 +18,11 @@ class TestMainWindow(TestCase):
""" """
Registry.create() Registry.create()
self.registry = Registry() self.registry = Registry()
self.app = QtGui.QApplication([]) old_app_instance = QtCore.QCoreApplication.instance()
if old_app_instance is None:
self.app = QtGui.QApplication([])
else:
self.app = old_app_instance
# Mock cursor busy/normal methods. # Mock cursor busy/normal methods.
self.app.set_busy_cursor = MagicMock() self.app.set_busy_cursor = MagicMock()
self.app.set_normal_cursor = MagicMock() self.app.set_normal_cursor = MagicMock()
@ -42,7 +46,6 @@ class TestMainWindow(TestCase):
Delete all the C++ objects at the end so that we don't have a segfault Delete all the C++ objects at the end so that we don't have a segfault
""" """
del self.main_window del self.main_window
del self.app
def restore_current_media_manager_item_test(self): def restore_current_media_manager_item_test(self):
""" """

View File

@ -19,7 +19,11 @@ class TestServiceManager(TestCase):
Create the UI Create the UI
""" """
Registry.create() Registry.create()
self.app = QtGui.QApplication([]) old_app_instance = QtCore.QCoreApplication.instance()
if old_app_instance is None:
self.app = QtGui.QApplication([])
else:
self.app = old_app_instance
ScreenList.create(self.app.desktop()) ScreenList.create(self.app.desktop())
Registry().register('application', MagicMock()) Registry().register('application', MagicMock())
with patch('openlp.core.lib.PluginManager'): with patch('openlp.core.lib.PluginManager'):
@ -31,7 +35,6 @@ class TestServiceManager(TestCase):
Delete all the C++ objects at the end so that we don't have a segfault Delete all the C++ objects at the end so that we don't have a segfault
""" """
del self.main_window del self.main_window
del self.app
def basic_service_manager_test(self): def basic_service_manager_test(self):
""" """

View File

@ -17,7 +17,11 @@ class TestStartNoteDialog(TestCase):
Create the UI Create the UI
""" """
Registry.create() Registry.create()
self.app = QtGui.QApplication([]) old_app_instance = QtCore.QCoreApplication.instance()
if old_app_instance is None:
self.app = QtGui.QApplication([])
else:
self.app = old_app_instance
self.main_window = QtGui.QMainWindow() self.main_window = QtGui.QMainWindow()
Registry().register('main_window', self.main_window) Registry().register('main_window', self.main_window)
self.form = servicenoteform.ServiceNoteForm() self.form = servicenoteform.ServiceNoteForm()
@ -28,7 +32,6 @@ class TestStartNoteDialog(TestCase):
""" """
del self.form del self.form
del self.main_window del self.main_window
del self.app
def basic_display_test(self): def basic_display_test(self):
""" """

View File

@ -31,7 +31,11 @@ class TestSettingsForm(TestCase):
self.dummy2 = MagicMock() self.dummy2 = MagicMock()
self.dummy3 = MagicMock() self.dummy3 = MagicMock()
self.desktop = MagicMock() self.desktop = MagicMock()
self.app = QtGui.QApplication([]) old_app_instance = QtCore.QCoreApplication.instance()
if old_app_instance is None:
self.app = QtGui.QApplication([])
else:
self.app = old_app_instance
self.desktop.primaryScreen.return_value = SCREEN['primary'] self.desktop.primaryScreen.return_value = SCREEN['primary']
self.desktop.screenCount.return_value = SCREEN['number'] self.desktop.screenCount.return_value = SCREEN['number']
self.desktop.screenGeometry.return_value = SCREEN['size'] self.desktop.screenGeometry.return_value = SCREEN['size']
@ -44,7 +48,6 @@ class TestSettingsForm(TestCase):
Delete all the C++ objects at the end so that we don't have a segfault Delete all the C++ objects at the end so that we don't have a segfault
""" """
del self.form del self.form
del self.app
def basic_cancel_test(self): def basic_cancel_test(self):
""" """

View File

@ -17,7 +17,11 @@ class TestStartTimeDialog(TestCase):
Create the UI Create the UI
""" """
Registry.create() Registry.create()
self.app = QtGui.QApplication([]) old_app_instance = QtCore.QCoreApplication.instance()
if old_app_instance is None:
self.app = QtGui.QApplication([])
else:
self.app = old_app_instance
self.main_window = QtGui.QMainWindow() self.main_window = QtGui.QMainWindow()
Registry().register('main_window', self.main_window) Registry().register('main_window', self.main_window)
self.form = starttimeform.StartTimeForm() self.form = starttimeform.StartTimeForm()
@ -28,7 +32,6 @@ class TestStartTimeDialog(TestCase):
""" """
del self.form del self.form
del self.main_window del self.main_window
del self.app
def ui_defaults_test(self): def ui_defaults_test(self):
""" """

View File

@ -33,7 +33,7 @@ import os
from unittest import TestCase from unittest import TestCase
from tempfile import mkstemp from tempfile import mkstemp
from PyQt4 import QtGui from PyQt4 import QtGui, QtCore
from openlp.core.common import Registry, Settings from openlp.core.common import Registry, Settings
from openlp.core.ui import ThemeManager from openlp.core.ui import ThemeManager
@ -51,7 +51,11 @@ class TestThemeManager(TestCase):
Settings.setDefaultFormat(Settings.IniFormat) Settings.setDefaultFormat(Settings.IniFormat)
fd, self.ini_file = mkstemp('.ini') fd, self.ini_file = mkstemp('.ini')
Settings().set_filename(self.ini_file) Settings().set_filename(self.ini_file)
self.app = QtGui.QApplication([]) old_app_instance = QtCore.QCoreApplication.instance()
if old_app_instance is None:
self.app = QtGui.QApplication([])
else:
self.app = old_app_instance
Registry.create() Registry.create()
self.theme_manager = ThemeManager() self.theme_manager = ThemeManager()
@ -60,7 +64,6 @@ class TestThemeManager(TestCase):
Delete all the C++ objects at the end so that we don't have a segfault Delete all the C++ objects at the end so that we don't have a segfault
""" """
os.unlink(Settings().fileName()) os.unlink(Settings().fileName())
del self.app
def initialise_test(self): def initialise_test(self):
""" """

View File

@ -21,7 +21,11 @@ class TestEditCustomForm(TestCase):
Create the UI Create the UI
""" """
Registry.create() Registry.create()
self.app = QtGui.QApplication([]) old_app_instance = QtCore.QCoreApplication.instance()
if old_app_instance is None:
self.app = QtGui.QApplication([])
else:
self.app = old_app_instance
self.main_window = QtGui.QMainWindow() self.main_window = QtGui.QMainWindow()
Registry().register('main_window', self.main_window) Registry().register('main_window', self.main_window)
media_item = MagicMock() media_item = MagicMock()
@ -34,7 +38,6 @@ class TestEditCustomForm(TestCase):
""" """
del self.form del self.form
del self.main_window del self.main_window
del self.app
def load_themes_test(self): def load_themes_test(self):
""" """

View File

@ -3,7 +3,7 @@ Module to test the EditCustomSlideForm.
""" """
from unittest import TestCase from unittest import TestCase
from PyQt4 import QtGui from PyQt4 import QtGui, QtCore
from openlp.core.common import Registry from openlp.core.common import Registry
from openlp.plugins.custom.forms.editcustomslideform import EditCustomSlideForm from openlp.plugins.custom.forms.editcustomslideform import EditCustomSlideForm
@ -19,7 +19,11 @@ class TestEditCustomSlideForm(TestCase):
Create the UI Create the UI
""" """
Registry.create() Registry.create()
self.app = QtGui.QApplication([]) old_app_instance = QtCore.QCoreApplication.instance()
if old_app_instance is None:
self.app = QtGui.QApplication([])
else:
self.app = old_app_instance
self.main_window = QtGui.QMainWindow() self.main_window = QtGui.QMainWindow()
Registry().register('main_window', self.main_window) Registry().register('main_window', self.main_window)
self.form = EditCustomSlideForm() self.form = EditCustomSlideForm()
@ -30,7 +34,6 @@ class TestEditCustomSlideForm(TestCase):
""" """
del self.form del self.form
del self.main_window del self.main_window
del self.app
def basic_test(self): def basic_test(self):
""" """

View File

@ -3,7 +3,7 @@ Package to test the openlp.plugins.songs.forms.authorsform package.
""" """
from unittest import TestCase from unittest import TestCase
from PyQt4 import QtGui from PyQt4 import QtGui, QtCore
from openlp.core.common import Registry from openlp.core.common import Registry
from openlp.plugins.songs.forms.authorsform import AuthorsForm from openlp.plugins.songs.forms.authorsform import AuthorsForm
@ -19,7 +19,11 @@ class TestAuthorsForm(TestCase):
Create the UI Create the UI
""" """
Registry.create() Registry.create()
self.app = QtGui.QApplication([]) old_app_instance = QtCore.QCoreApplication.instance()
if old_app_instance is None:
self.app = QtGui.QApplication([])
else:
self.app = old_app_instance
self.main_window = QtGui.QMainWindow() self.main_window = QtGui.QMainWindow()
Registry().register('main_window', self.main_window) Registry().register('main_window', self.main_window)
self.form = AuthorsForm() self.form = AuthorsForm()
@ -30,7 +34,6 @@ class TestAuthorsForm(TestCase):
""" """
del self.form del self.form
del self.main_window del self.main_window
del self.app
def ui_defaults_test(self): def ui_defaults_test(self):
""" """

View File

@ -3,7 +3,7 @@ Package to test the openlp.plugins.songs.forms.editsongform package.
""" """
from unittest import TestCase from unittest import TestCase
from PyQt4 import QtGui from PyQt4 import QtGui, QtCore
from openlp.core.common import Registry from openlp.core.common import Registry
from openlp.plugins.songs.forms.editsongform import EditSongForm from openlp.plugins.songs.forms.editsongform import EditSongForm
@ -20,7 +20,11 @@ class TestEditSongForm(TestCase):
Create the UI Create the UI
""" """
Registry.create() Registry.create()
self.app = QtGui.QApplication([]) old_app_instance = QtCore.QCoreApplication.instance()
if old_app_instance is None:
self.app = QtGui.QApplication([])
else:
self.app = old_app_instance
self.main_window = QtGui.QMainWindow() self.main_window = QtGui.QMainWindow()
Registry().register('main_window', self.main_window) Registry().register('main_window', self.main_window)
Registry().register('theme_manager', MagicMock()) Registry().register('theme_manager', MagicMock())
@ -32,7 +36,6 @@ class TestEditSongForm(TestCase):
""" """
del self.form del self.form
del self.main_window del self.main_window
del self.app
def ui_defaults_test(self): def ui_defaults_test(self):
""" """

View File

@ -19,7 +19,11 @@ class TestEditVerseForm(TestCase):
Create the UI Create the UI
""" """
Registry.create() Registry.create()
self.app = QtGui.QApplication([]) old_app_instance = QtCore.QCoreApplication.instance()
if old_app_instance is None:
self.app = QtGui.QApplication([])
else:
self.app = old_app_instance
self.main_window = QtGui.QMainWindow() self.main_window = QtGui.QMainWindow()
Registry().register('main_window', self.main_window) Registry().register('main_window', self.main_window)
self.form = EditVerseForm() self.form = EditVerseForm()
@ -30,7 +34,6 @@ class TestEditVerseForm(TestCase):
""" """
del self.form del self.form
del self.main_window del self.main_window
del self.app
def ui_defaults_test(self): def ui_defaults_test(self):
""" """

View File

@ -3,7 +3,7 @@ Package to test the openlp.plugins.songs.forms.topicsform package.
""" """
from unittest import TestCase from unittest import TestCase
from PyQt4 import QtGui from PyQt4 import QtGui, QtCore
from openlp.core.common import Registry from openlp.core.common import Registry
from openlp.plugins.songs.forms.topicsform import TopicsForm from openlp.plugins.songs.forms.topicsform import TopicsForm
@ -19,7 +19,11 @@ class TestTopicsForm(TestCase):
Create the UI Create the UI
""" """
Registry.create() Registry.create()
self.app = QtGui.QApplication([]) old_app_instance = QtCore.QCoreApplication.instance()
if old_app_instance is None:
self.app = QtGui.QApplication([])
else:
self.app = old_app_instance
self.main_window = QtGui.QMainWindow() self.main_window = QtGui.QMainWindow()
Registry().register('main_window', self.main_window) Registry().register('main_window', self.main_window)
self.form = TopicsForm() self.form = TopicsForm()
@ -30,7 +34,6 @@ class TestTopicsForm(TestCase):
""" """
del self.form del self.form
del self.main_window del self.main_window
del self.app
def ui_defaults_test(self): def ui_defaults_test(self):
""" """