more Py3 fixes

This commit is contained in:
Philip Ridout 2013-09-15 20:42:29 +01:00
parent 9f5bd87a50
commit 52781b9628
2 changed files with 16 additions and 16 deletions

View File

@ -370,8 +370,8 @@ def create_separated_list(stringlist):
'Locale list separator: end') % (stringlist[-2], stringlist[-1]) 'Locale list separator: end') % (stringlist[-2], stringlist[-1])
for index in reversed(list(range(1, len(stringlist) - 2))): for index in reversed(list(range(1, len(stringlist) - 2))):
merged = translate('OpenLP.core.lib', '%s, %s', merged = translate('OpenLP.core.lib', '%s, %s',
u'Locale list separator: middle') % (stringlist[index], merged) 'Locale list separator: middle') % (stringlist[index], merged)
return translate('OpenLP.core.lib', '%s, %s', u'Locale list separator: start') % (stringlist[0], merged) return translate('OpenLP.core.lib', '%s, %s', 'Locale list separator: start') % (stringlist[0], merged)
from .registry import Registry from .registry import Registry
@ -392,4 +392,4 @@ from .toolbar import OpenLPToolbar
from .dockwidget import OpenLPDockWidget from .dockwidget import OpenLPDockWidget
from .imagemanager import ImageManager from .imagemanager import ImageManager
from .renderer import Renderer from .renderer import Renderer
from .mediamanageritem import MediaManagerItem from .mediamanageritem import MediaManagerItem

View File

@ -1,5 +1,5 @@
""" """
Package to test the openlp.core.lib.formattingtags package. Package to test the openlp.core.lib.filedialog package.
""" """
import copy import copy
from unittest import TestCase from unittest import TestCase
@ -13,9 +13,9 @@ class TestFileDialog(TestCase):
Test the functions in the :mod:`filedialog` module. Test the functions in the :mod:`filedialog` module.
""" """
def setUp(self): def setUp(self):
self.os_patcher = patch(u'openlp.core.lib.filedialog.os') self.os_patcher = patch('openlp.core.lib.filedialog.os')
self.qt_gui_patcher = patch(u'openlp.core.lib.filedialog.QtGui') self.qt_gui_patcher = patch('openlp.core.lib.filedialog.QtGui')
self.ui_strings_patcher = patch(u'openlp.core.lib.filedialog.UiStrings') self.ui_strings_patcher = patch('openlp.core.lib.filedialog.UiStrings')
self.mocked_os = self.os_patcher.start() self.mocked_os = self.os_patcher.start()
self.mocked_qt_gui = self.qt_gui_patcher.start() self.mocked_qt_gui = self.qt_gui_patcher.start()
self.mocked_ui_strings = self.ui_strings_patcher.start() self.mocked_ui_strings = self.ui_strings_patcher.start()
@ -39,10 +39,10 @@ class TestFileDialog(TestCase):
# WHEN: FileDialog.getOpenFileNames is called # WHEN: FileDialog.getOpenFileNames is called
result = FileDialog.getOpenFileNames(self.mocked_parent) 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 assert not self.mocked_os.path.exists.called
self.assertEqual(result, [], 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): def returned_file_list_test(self):
""" """
@ -52,20 +52,20 @@ class TestFileDialog(TestCase):
self.mocked_os.rest() self.mocked_os.rest()
self.mocked_qt_gui.reset() 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. # file names.
self.mocked_qt_gui.QFileDialog.getOpenFileNames.return_value = [ 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 [ 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 # WHEN: FileDialog.getOpenFileNames is called
result = FileDialog.getOpenFileNames(self.mocked_parent) result = FileDialog.getOpenFileNames(self.mocked_parent)
# THEN: os.path.exists should have been called with known args. QmessageBox.information should have been # 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. # 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'), self.mocked_os.path.exists.assert_has_calls([call('/Valid File'), call('/url%20encoded%20file%20%231'),
call(u'/url encoded file #1'), call(u'/non-existing'), call(u'/non-existing')]) call('/url encoded file #1'), call('/non-existing'), call('/non-existing')])
self.mocked_qt_gui.QmessageBox.information.called_with(self.mocked_parent, UiStrings().FileNotFound, self.mocked_qt_gui.QmessageBox.information.called_with(self.mocked_parent, UiStrings().FileNotFound,
UiStrings().FileNotFoundMessage % u'/non-existing') UiStrings().FileNotFoundMessage % '/non-existing')
self.assertEqual(result, [u'/Valid File', u'/url encoded file #1'], u'The returned file list is incorrect') self.assertEqual(result, ['/Valid File', '/url encoded file #1'], 'The returned file list is incorrect')