forked from openlp/openlp
more Py3 fixes
This commit is contained in:
parent
9f5bd87a50
commit
52781b9628
@ -370,8 +370,8 @@ def create_separated_list(stringlist):
|
||||
'Locale list separator: end') % (stringlist[-2], stringlist[-1])
|
||||
for index in reversed(list(range(1, len(stringlist) - 2))):
|
||||
merged = translate('OpenLP.core.lib', '%s, %s',
|
||||
u'Locale list separator: middle') % (stringlist[index], merged)
|
||||
return translate('OpenLP.core.lib', '%s, %s', u'Locale list separator: start') % (stringlist[0], merged)
|
||||
'Locale list separator: middle') % (stringlist[index], merged)
|
||||
return translate('OpenLP.core.lib', '%s, %s', 'Locale list separator: start') % (stringlist[0], merged)
|
||||
|
||||
|
||||
from .registry import Registry
|
||||
@ -392,4 +392,4 @@ from .toolbar import OpenLPToolbar
|
||||
from .dockwidget import OpenLPDockWidget
|
||||
from .imagemanager import ImageManager
|
||||
from .renderer import Renderer
|
||||
from .mediamanageritem import MediaManagerItem
|
||||
from .mediamanageritem import MediaManagerItem
|
||||
|
@ -1,5 +1,5 @@
|
||||
"""
|
||||
Package to test the openlp.core.lib.formattingtags package.
|
||||
Package to test the openlp.core.lib.filedialog package.
|
||||
"""
|
||||
import copy
|
||||
from unittest import TestCase
|
||||
@ -13,9 +13,9 @@ class TestFileDialog(TestCase):
|
||||
Test the functions in the :mod:`filedialog` module.
|
||||
"""
|
||||
def setUp(self):
|
||||
self.os_patcher = patch(u'openlp.core.lib.filedialog.os')
|
||||
self.qt_gui_patcher = patch(u'openlp.core.lib.filedialog.QtGui')
|
||||
self.ui_strings_patcher = patch(u'openlp.core.lib.filedialog.UiStrings')
|
||||
self.os_patcher = patch('openlp.core.lib.filedialog.os')
|
||||
self.qt_gui_patcher = patch('openlp.core.lib.filedialog.QtGui')
|
||||
self.ui_strings_patcher = patch('openlp.core.lib.filedialog.UiStrings')
|
||||
self.mocked_os = self.os_patcher.start()
|
||||
self.mocked_qt_gui = self.qt_gui_patcher.start()
|
||||
self.mocked_ui_strings = self.ui_strings_patcher.start()
|
||||
@ -39,10 +39,10 @@ class TestFileDialog(TestCase):
|
||||
# WHEN: FileDialog.getOpenFileNames is called
|
||||
result = FileDialog.getOpenFileNames(self.mocked_parent)
|
||||
|
||||
# THEN: The returned value should be an empty QStiingList and os.path.exists should not have been called
|
||||
# THEN: The returned value should be an empty QStringList and os.path.exists should not have been called
|
||||
assert not self.mocked_os.path.exists.called
|
||||
self.assertEqual(result, [],
|
||||
u'FileDialog.getOpenFileNames should return and empty list when QFileDialog.getOpenFileNames is canceled')
|
||||
'FileDialog.getOpenFileNames should return and empty list when QFileDialog.getOpenFileNames is canceled')
|
||||
|
||||
def returned_file_list_test(self):
|
||||
"""
|
||||
@ -52,20 +52,20 @@ class TestFileDialog(TestCase):
|
||||
self.mocked_os.rest()
|
||||
self.mocked_qt_gui.reset()
|
||||
|
||||
# GIVEN: A List of known values as a return value from QFileDialog.getOpenFileNamesand a list of valid
|
||||
# GIVEN: A List of known values as a return value from QFileDialog.getOpenFileNames and a list of valid
|
||||
# file names.
|
||||
self.mocked_qt_gui.QFileDialog.getOpenFileNames.return_value = [
|
||||
u'/Valid File', u'/url%20encoded%20file%20%231', u'/non-existing']
|
||||
'/Valid File', '/url%20encoded%20file%20%231', '/non-existing']
|
||||
self.mocked_os.path.exists.side_effect = lambda file_name: file_name in [
|
||||
u'/Valid File', u'/url encoded file #1']
|
||||
'/Valid File', '/url encoded file #1']
|
||||
|
||||
# WHEN: FileDialog.getOpenFileNames is called
|
||||
result = FileDialog.getOpenFileNames(self.mocked_parent)
|
||||
|
||||
# THEN: os.path.exists should have been called with known args. QmessageBox.information should have been
|
||||
# called. The returned result should corrilate with the input.
|
||||
self.mocked_os.path.exists.assert_has_calls([call(u'/Valid File'), call(u'/url%20encoded%20file%20%231'),
|
||||
call(u'/url encoded file #1'), call(u'/non-existing'), call(u'/non-existing')])
|
||||
self.mocked_os.path.exists.assert_has_calls([call('/Valid File'), call('/url%20encoded%20file%20%231'),
|
||||
call('/url encoded file #1'), call('/non-existing'), call('/non-existing')])
|
||||
self.mocked_qt_gui.QmessageBox.information.called_with(self.mocked_parent, UiStrings().FileNotFound,
|
||||
UiStrings().FileNotFoundMessage % u'/non-existing')
|
||||
self.assertEqual(result, [u'/Valid File', u'/url encoded file #1'], u'The returned file list is incorrect')
|
||||
UiStrings().FileNotFoundMessage % '/non-existing')
|
||||
self.assertEqual(result, ['/Valid File', '/url encoded file #1'], 'The returned file list is incorrect')
|
Loading…
Reference in New Issue
Block a user