forked from openlp/openlp
Merge trunk
This commit is contained in:
commit
af5e751d27
@ -426,9 +426,9 @@ def get_locale_key(string):
|
||||
The corresponding string.
|
||||
"""
|
||||
string = string.lower()
|
||||
# For Python 3 on platforms other than Windows ICU is not necessary. In those cases locale.strxfrm(str) can be used.
|
||||
if os.name == 'nt':
|
||||
# ICU is the prefered way to handle locale sort key, we fallback to locale.strxfrm which will work in most cases.
|
||||
global ICU_COLLATOR
|
||||
try:
|
||||
if ICU_COLLATOR is None:
|
||||
import icu
|
||||
from .languagemanager import LanguageManager
|
||||
@ -436,9 +436,9 @@ def get_locale_key(string):
|
||||
icu_locale = icu.Locale(language)
|
||||
ICU_COLLATOR = icu.Collator.createInstance(icu_locale)
|
||||
return ICU_COLLATOR.getSortKey(string)
|
||||
except:
|
||||
return locale.strxfrm(string).encode()
|
||||
|
||||
|
||||
def get_natural_key(string):
|
||||
"""
|
||||
Generate a key for locale aware natural string sorting.
|
||||
|
@ -7,7 +7,7 @@ import shutil
|
||||
from tempfile import mkstemp, mkdtemp
|
||||
from unittest import TestCase
|
||||
|
||||
from PyQt4 import QtGui
|
||||
from PyQt4 import QtGui, QtCore
|
||||
|
||||
from openlp.core.common import Registry, Settings
|
||||
from openlp.core.lib.pluginmanager import PluginManager
|
||||
@ -30,12 +30,15 @@ class TestPluginManager(TestCase):
|
||||
Settings().setValue('advanced/data path', self.temp_dir)
|
||||
Registry.create()
|
||||
Registry().register('service_list', MagicMock())
|
||||
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()
|
||||
Registry().register('main_window', self.main_window)
|
||||
|
||||
def tearDown(self):
|
||||
del self.app
|
||||
del self.main_window
|
||||
Settings().remove('advanced/data path')
|
||||
shutil.rmtree(self.temp_dir)
|
||||
|
@ -3,7 +3,7 @@
|
||||
"""
|
||||
from unittest import TestCase
|
||||
|
||||
from PyQt4 import QtGui, QtTest
|
||||
from PyQt4 import QtCore, QtGui, QtTest
|
||||
|
||||
from openlp.core.common import Registry
|
||||
from openlp.core.ui import filerenameform
|
||||
@ -17,7 +17,11 @@ class TestStartFileRenameForm(TestCase):
|
||||
Create the UI
|
||||
"""
|
||||
Registry.create()
|
||||
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()
|
||||
Registry().register('main_window', self.main_window)
|
||||
self.form = filerenameform.FileRenameForm()
|
||||
@ -28,7 +32,6 @@ class TestStartFileRenameForm(TestCase):
|
||||
"""
|
||||
del self.form
|
||||
del self.main_window
|
||||
del self.app
|
||||
|
||||
def window_title_test(self):
|
||||
"""
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
from unittest import TestCase
|
||||
|
||||
from PyQt4 import QtGui
|
||||
from PyQt4 import QtGui, QtCore
|
||||
|
||||
from openlp.core.common import Registry
|
||||
from openlp.core.lib import ServiceItem
|
||||
@ -20,7 +20,11 @@ class TestListPreviewWidget(TestCase):
|
||||
Create the UI.
|
||||
"""
|
||||
Registry.create()
|
||||
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.image = QtGui.QImage(1, 1, QtGui.QImage.Format_RGB32)
|
||||
self.image_manager = MagicMock()
|
||||
@ -34,7 +38,6 @@ class TestListPreviewWidget(TestCase):
|
||||
"""
|
||||
del self.preview_widget
|
||||
del self.main_window
|
||||
del self.app
|
||||
|
||||
def initial_slide_count_test(self):
|
||||
"""
|
||||
|
@ -3,7 +3,7 @@ Package to test the openlp.core.ui.mainwindow package.
|
||||
"""
|
||||
from unittest import TestCase
|
||||
|
||||
from PyQt4 import QtGui
|
||||
from PyQt4 import QtGui, QtCore
|
||||
|
||||
from openlp.core.common import Registry
|
||||
from openlp.core.ui.mainwindow import MainWindow
|
||||
@ -18,7 +18,11 @@ class TestMainWindow(TestCase):
|
||||
"""
|
||||
Registry.create()
|
||||
self.registry = Registry()
|
||||
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.
|
||||
self.app.set_busy_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
|
||||
"""
|
||||
del self.main_window
|
||||
del self.app
|
||||
|
||||
def restore_current_media_manager_item_test(self):
|
||||
"""
|
||||
|
@ -19,7 +19,11 @@ class TestServiceManager(TestCase):
|
||||
Create the UI
|
||||
"""
|
||||
Registry.create()
|
||||
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())
|
||||
Registry().register('application', MagicMock())
|
||||
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
|
||||
"""
|
||||
del self.main_window
|
||||
del self.app
|
||||
|
||||
def basic_service_manager_test(self):
|
||||
"""
|
||||
|
@ -17,7 +17,11 @@ class TestStartNoteDialog(TestCase):
|
||||
Create the UI
|
||||
"""
|
||||
Registry.create()
|
||||
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()
|
||||
Registry().register('main_window', self.main_window)
|
||||
self.form = servicenoteform.ServiceNoteForm()
|
||||
@ -28,7 +32,6 @@ class TestStartNoteDialog(TestCase):
|
||||
"""
|
||||
del self.form
|
||||
del self.main_window
|
||||
del self.app
|
||||
|
||||
def basic_display_test(self):
|
||||
"""
|
||||
|
@ -31,7 +31,11 @@ class TestSettingsForm(TestCase):
|
||||
self.dummy2 = MagicMock()
|
||||
self.dummy3 = MagicMock()
|
||||
self.desktop = MagicMock()
|
||||
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.screenCount.return_value = SCREEN['number']
|
||||
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
|
||||
"""
|
||||
del self.form
|
||||
del self.app
|
||||
|
||||
def basic_cancel_test(self):
|
||||
"""
|
||||
|
@ -17,7 +17,11 @@ class TestStartTimeDialog(TestCase):
|
||||
Create the UI
|
||||
"""
|
||||
Registry.create()
|
||||
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()
|
||||
Registry().register('main_window', self.main_window)
|
||||
self.form = starttimeform.StartTimeForm()
|
||||
@ -28,7 +32,6 @@ class TestStartTimeDialog(TestCase):
|
||||
"""
|
||||
del self.form
|
||||
del self.main_window
|
||||
del self.app
|
||||
|
||||
def ui_defaults_test(self):
|
||||
"""
|
||||
|
@ -33,7 +33,7 @@ import os
|
||||
from unittest import TestCase
|
||||
from tempfile import mkstemp
|
||||
|
||||
from PyQt4 import QtGui
|
||||
from PyQt4 import QtGui, QtCore
|
||||
|
||||
from openlp.core.common import Registry, Settings
|
||||
from openlp.core.ui import ThemeManager
|
||||
@ -51,7 +51,11 @@ class TestThemeManager(TestCase):
|
||||
Settings.setDefaultFormat(Settings.IniFormat)
|
||||
fd, self.ini_file = mkstemp('.ini')
|
||||
Settings().set_filename(self.ini_file)
|
||||
old_app_instance = QtCore.QCoreApplication.instance()
|
||||
if old_app_instance is None:
|
||||
self.app = QtGui.QApplication([])
|
||||
else:
|
||||
self.app = old_app_instance
|
||||
Registry.create()
|
||||
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
|
||||
"""
|
||||
os.unlink(Settings().fileName())
|
||||
del self.app
|
||||
|
||||
def initialise_test(self):
|
||||
"""
|
||||
|
@ -21,7 +21,11 @@ class TestEditCustomForm(TestCase):
|
||||
Create the UI
|
||||
"""
|
||||
Registry.create()
|
||||
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()
|
||||
Registry().register('main_window', self.main_window)
|
||||
media_item = MagicMock()
|
||||
@ -34,7 +38,6 @@ class TestEditCustomForm(TestCase):
|
||||
"""
|
||||
del self.form
|
||||
del self.main_window
|
||||
del self.app
|
||||
|
||||
def load_themes_test(self):
|
||||
"""
|
||||
|
@ -3,7 +3,7 @@ Module to test the EditCustomSlideForm.
|
||||
"""
|
||||
from unittest import TestCase
|
||||
|
||||
from PyQt4 import QtGui
|
||||
from PyQt4 import QtGui, QtCore
|
||||
|
||||
from openlp.core.common import Registry
|
||||
from openlp.plugins.custom.forms.editcustomslideform import EditCustomSlideForm
|
||||
@ -19,7 +19,11 @@ class TestEditCustomSlideForm(TestCase):
|
||||
Create the UI
|
||||
"""
|
||||
Registry.create()
|
||||
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()
|
||||
Registry().register('main_window', self.main_window)
|
||||
self.form = EditCustomSlideForm()
|
||||
@ -30,7 +34,6 @@ class TestEditCustomSlideForm(TestCase):
|
||||
"""
|
||||
del self.form
|
||||
del self.main_window
|
||||
del self.app
|
||||
|
||||
def basic_test(self):
|
||||
"""
|
||||
|
@ -3,7 +3,7 @@ Package to test the openlp.plugins.songs.forms.authorsform package.
|
||||
"""
|
||||
from unittest import TestCase
|
||||
|
||||
from PyQt4 import QtGui
|
||||
from PyQt4 import QtGui, QtCore
|
||||
|
||||
from openlp.core.common import Registry
|
||||
from openlp.plugins.songs.forms.authorsform import AuthorsForm
|
||||
@ -19,7 +19,11 @@ class TestAuthorsForm(TestCase):
|
||||
Create the UI
|
||||
"""
|
||||
Registry.create()
|
||||
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()
|
||||
Registry().register('main_window', self.main_window)
|
||||
self.form = AuthorsForm()
|
||||
@ -30,7 +34,6 @@ class TestAuthorsForm(TestCase):
|
||||
"""
|
||||
del self.form
|
||||
del self.main_window
|
||||
del self.app
|
||||
|
||||
def ui_defaults_test(self):
|
||||
"""
|
||||
|
@ -3,7 +3,7 @@ Package to test the openlp.plugins.songs.forms.editsongform package.
|
||||
"""
|
||||
from unittest import TestCase
|
||||
|
||||
from PyQt4 import QtGui
|
||||
from PyQt4 import QtGui, QtCore
|
||||
|
||||
from openlp.core.common import Registry
|
||||
from openlp.plugins.songs.forms.editsongform import EditSongForm
|
||||
@ -20,7 +20,11 @@ class TestEditSongForm(TestCase):
|
||||
Create the UI
|
||||
"""
|
||||
Registry.create()
|
||||
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()
|
||||
Registry().register('main_window', self.main_window)
|
||||
Registry().register('theme_manager', MagicMock())
|
||||
@ -32,7 +36,6 @@ class TestEditSongForm(TestCase):
|
||||
"""
|
||||
del self.form
|
||||
del self.main_window
|
||||
del self.app
|
||||
|
||||
def ui_defaults_test(self):
|
||||
"""
|
||||
|
@ -19,7 +19,11 @@ class TestEditVerseForm(TestCase):
|
||||
Create the UI
|
||||
"""
|
||||
Registry.create()
|
||||
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()
|
||||
Registry().register('main_window', self.main_window)
|
||||
self.form = EditVerseForm()
|
||||
@ -30,7 +34,6 @@ class TestEditVerseForm(TestCase):
|
||||
"""
|
||||
del self.form
|
||||
del self.main_window
|
||||
del self.app
|
||||
|
||||
def ui_defaults_test(self):
|
||||
"""
|
||||
|
@ -3,7 +3,7 @@ Package to test the openlp.plugins.songs.forms.topicsform package.
|
||||
"""
|
||||
from unittest import TestCase
|
||||
|
||||
from PyQt4 import QtGui
|
||||
from PyQt4 import QtGui, QtCore
|
||||
|
||||
from openlp.core.common import Registry
|
||||
from openlp.plugins.songs.forms.topicsform import TopicsForm
|
||||
@ -19,7 +19,11 @@ class TestTopicsForm(TestCase):
|
||||
Create the UI
|
||||
"""
|
||||
Registry.create()
|
||||
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()
|
||||
Registry().register('main_window', self.main_window)
|
||||
self.form = TopicsForm()
|
||||
@ -30,7 +34,6 @@ class TestTopicsForm(TestCase):
|
||||
"""
|
||||
del self.form
|
||||
del self.main_window
|
||||
del self.app
|
||||
|
||||
def ui_defaults_test(self):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user