From e4c3f08a2a82a70eb9b4bb0e20f2308b63d102eb Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Sat, 29 Mar 2014 15:31:28 +0200 Subject: [PATCH] Fix some of the tests which were failing in Python 3.4 --- openlp/plugins/songs/lib/easyslidesimport.py | 2 +- openlp/plugins/songs/lib/ewimport.py | 2 +- openlp/plugins/songs/lib/songbeamerimport.py | 2 +- .../plugins/songs/lib/songshowplusimport.py | 2 +- .../openlp_plugins/songs/test_ewimport.py | 22 +++++++++---------- .../songs/test_songbeamerimport.py | 8 +++---- .../songs/test_songshowplusimport.py | 10 ++++----- tests/helpers/songfileimport.py | 2 +- 8 files changed, 25 insertions(+), 25 deletions(-) diff --git a/openlp/plugins/songs/lib/easyslidesimport.py b/openlp/plugins/songs/lib/easyslidesimport.py index 628d64880..e28e7bf97 100644 --- a/openlp/plugins/songs/lib/easyslidesimport.py +++ b/openlp/plugins/songs/lib/easyslidesimport.py @@ -49,7 +49,7 @@ class EasySlidesImport(SongImport): """ Initialise the class. """ - SongImport.__init__(self, manager, **kwargs) + super(EasySlidesImport, self).__init__(manager, **kwargs) def do_import(self): log.info('Importing EasySlides XML file %s', self.import_source) diff --git a/openlp/plugins/songs/lib/ewimport.py b/openlp/plugins/songs/lib/ewimport.py index 9e3ae566e..cde0b1692 100644 --- a/openlp/plugins/songs/lib/ewimport.py +++ b/openlp/plugins/songs/lib/ewimport.py @@ -73,7 +73,7 @@ class EasyWorshipSongImport(SongImport): ability to import EasyWorship song files. """ def __init__(self, manager, **kwargs): - SongImport.__init__(self, manager, **kwargs) + super(EasyWorshipSongImport, self).__init__(manager, **kwargs) def do_import(self): """ diff --git a/openlp/plugins/songs/lib/songbeamerimport.py b/openlp/plugins/songs/lib/songbeamerimport.py index 4de763554..0106ca687 100644 --- a/openlp/plugins/songs/lib/songbeamerimport.py +++ b/openlp/plugins/songs/lib/songbeamerimport.py @@ -97,7 +97,7 @@ class SongBeamerImport(SongImport): """ Initialise the Song Beamer importer. """ - SongImport.__init__(self, manager, **kwargs) + super(SongBeamerImport, self).__init__(manager, **kwargs) def do_import(self): """ diff --git a/openlp/plugins/songs/lib/songshowplusimport.py b/openlp/plugins/songs/lib/songshowplusimport.py index 485a8f047..0a8dc4650 100644 --- a/openlp/plugins/songs/lib/songshowplusimport.py +++ b/openlp/plugins/songs/lib/songshowplusimport.py @@ -92,7 +92,7 @@ class SongShowPlusImport(SongImport): """ Initialise the SongShow Plus importer. """ - SongImport.__init__(self, manager, **kwargs) + super(SongShowPlusImport, self).__init__(manager, **kwargs) def do_import(self): """ diff --git a/tests/functional/openlp_plugins/songs/test_ewimport.py b/tests/functional/openlp_plugins/songs/test_ewimport.py index a22519bec..f98ba57d2 100644 --- a/tests/functional/openlp_plugins/songs/test_ewimport.py +++ b/tests/functional/openlp_plugins/songs/test_ewimport.py @@ -77,7 +77,7 @@ class EasyWorshipSongImportLogger(EasyWorshipSongImport): _title_assignment_list = [] def __init__(self, manager): - EasyWorshipSongImport.__init__(self, manager) + EasyWorshipSongImport.__init__(self, manager, filenames=[]) @property def title(self): @@ -147,7 +147,7 @@ class TestEasyWorshipSongImport(TestCase): mocked_manager = MagicMock() # WHEN: An importer object is created - importer = EasyWorshipSongImport(mocked_manager) + importer = EasyWorshipSongImport(mocked_manager, filenames=[]) # THEN: The importer object should not be None self.assertIsNotNone(importer, 'Import should not be none') @@ -159,7 +159,7 @@ class TestEasyWorshipSongImport(TestCase): # GIVEN: A mocked out SongImport class, a mocked out "manager" and a list of field descriptions. with patch('openlp.plugins.songs.lib.ewimport.SongImport'): mocked_manager = MagicMock() - importer = EasyWorshipSongImport(mocked_manager) + importer = EasyWorshipSongImport(mocked_manager, filenames=[]) importer.field_descriptions = TEST_FIELD_DESCS # WHEN: Called with a field name that exists @@ -177,7 +177,7 @@ class TestEasyWorshipSongImport(TestCase): # GIVEN: A mocked out SongImport class, a mocked out "manager" and a list of field descriptions with patch('openlp.plugins.songs.lib.ewimport.SongImport'): mocked_manager = MagicMock() - importer = EasyWorshipSongImport(mocked_manager) + importer = EasyWorshipSongImport(mocked_manager, filenames=[]) importer.field_descriptions = TEST_FIELD_DESCS # WHEN: Called with a field name that does not exist @@ -196,7 +196,7 @@ class TestEasyWorshipSongImport(TestCase): with patch('openlp.plugins.songs.lib.ewimport.SongImport'), \ patch('openlp.plugins.songs.lib.ewimport.struct') as mocked_struct: mocked_manager = MagicMock() - importer = EasyWorshipSongImport(mocked_manager) + importer = EasyWorshipSongImport(mocked_manager, filenames=[]) # WHEN: set_record_struct is called with a list of field descriptions return_value = importer.set_record_struct(TEST_FIELD_DESCS) @@ -213,7 +213,7 @@ class TestEasyWorshipSongImport(TestCase): # GIVEN: A mocked out SongImport class, a mocked out "manager", an encoding and some test data and known results with patch('openlp.plugins.songs.lib.ewimport.SongImport'): mocked_manager = MagicMock() - importer = EasyWorshipSongImport(mocked_manager) + importer = EasyWorshipSongImport(mocked_manager, filenames=[]) importer.encoding = TEST_DATA_ENCODING importer.fields = TEST_FIELDS importer.field_descriptions = TEST_FIELD_DESCS @@ -236,7 +236,7 @@ class TestEasyWorshipSongImport(TestCase): with patch('openlp.plugins.songs.lib.ewimport.SongImport'): mocked_manager = MagicMock() mocked_memo_file = MagicMock() - importer = EasyWorshipSongImport(mocked_manager) + importer = EasyWorshipSongImport(mocked_manager, filenames=[]) importer.memo_file = mocked_memo_file importer.encoding = TEST_DATA_ENCODING @@ -267,7 +267,7 @@ class TestEasyWorshipSongImport(TestCase): with patch('openlp.plugins.songs.lib.ewimport.SongImport'), \ patch('openlp.plugins.songs.lib.ewimport.os.path') as mocked_os_path: mocked_manager = MagicMock() - importer = EasyWorshipSongImport(mocked_manager) + importer = EasyWorshipSongImport(mocked_manager, filenames=[]) mocked_os_path.isfile.side_effect = [True, False] # WHEN: Supplied with an import source @@ -286,7 +286,7 @@ class TestEasyWorshipSongImport(TestCase): with patch('openlp.plugins.songs.lib.ewimport.SongImport'), \ patch('openlp.plugins.songs.lib.ewimport.os.path') as mocked_os_path: mocked_manager = MagicMock() - importer = EasyWorshipSongImport(mocked_manager) + importer = EasyWorshipSongImport(mocked_manager, filenames=[]) mocked_os_path.isfile.return_value = True importer.import_source = 'Songs.DB' @@ -307,7 +307,7 @@ class TestEasyWorshipSongImport(TestCase): patch('builtins.open') as mocked_open, \ patch('openlp.plugins.songs.lib.ewimport.struct') as mocked_struct: mocked_manager = MagicMock() - importer = EasyWorshipSongImport(mocked_manager) + importer = EasyWorshipSongImport(mocked_manager, filenames=[]) mocked_os_path.isfile.return_value = True mocked_os_path.getsize.return_value = 0x800 importer.import_source = 'Songs.DB' @@ -334,7 +334,7 @@ class TestEasyWorshipSongImport(TestCase): patch('builtins.open'), patch('openlp.plugins.songs.lib.ewimport.struct') as mocked_struct, \ patch('openlp.plugins.songs.lib.ewimport.retrieve_windows_encoding') as mocked_retrieve_windows_encoding: mocked_manager = MagicMock() - importer = EasyWorshipSongImport(mocked_manager) + importer = EasyWorshipSongImport(mocked_manager, filenames=[]) mocked_os_path.isfile.return_value = True mocked_os_path.getsize.return_value = 0x800 importer.import_source = 'Songs.DB' diff --git a/tests/functional/openlp_plugins/songs/test_songbeamerimport.py b/tests/functional/openlp_plugins/songs/test_songbeamerimport.py index 72901eb47..a968975b3 100644 --- a/tests/functional/openlp_plugins/songs/test_songbeamerimport.py +++ b/tests/functional/openlp_plugins/songs/test_songbeamerimport.py @@ -66,7 +66,7 @@ class TestSongBeamerImport(TestCase): mocked_manager = MagicMock() # WHEN: An importer object is created - importer = SongBeamerImport(mocked_manager) + importer = SongBeamerImport(mocked_manager, filenames=[]) # THEN: The importer object should not be None self.assertIsNotNone(importer, 'Import should not be none') @@ -79,7 +79,7 @@ class TestSongBeamerImport(TestCase): with patch('openlp.plugins.songs.lib.songbeamerimport.SongImport'): mocked_manager = MagicMock() mocked_import_wizard = MagicMock() - importer = SongBeamerImport(mocked_manager) + importer = SongBeamerImport(mocked_manager, filenames=[]) importer.import_wizard = mocked_import_wizard importer.stop_import_flag = True @@ -100,7 +100,7 @@ class TestSongBeamerImport(TestCase): with patch('openlp.plugins.songs.lib.songbeamerimport.SongImport'): mocked_manager = MagicMock() mocked_import_wizard = MagicMock() - importer = SongBeamerImport(mocked_manager) + importer = SongBeamerImport(mocked_manager, filenames=[]) importer.import_wizard = mocked_import_wizard importer.stop_import_flag = True @@ -127,7 +127,7 @@ class TestSongBeamerImport(TestCase): mocked_add_verse = MagicMock() mocked_finish = MagicMock() mocked_finish.return_value = True - importer = SongBeamerImport(mocked_manager) + importer = SongBeamerImport(mocked_manager, filenames=[]) importer.import_wizard = mocked_import_wizard importer.stop_import_flag = False importer.add_verse = mocked_add_verse diff --git a/tests/functional/openlp_plugins/songs/test_songshowplusimport.py b/tests/functional/openlp_plugins/songs/test_songshowplusimport.py index 5c945efb3..16af347b2 100644 --- a/tests/functional/openlp_plugins/songs/test_songshowplusimport.py +++ b/tests/functional/openlp_plugins/songs/test_songshowplusimport.py @@ -72,7 +72,7 @@ class TestSongShowPlusImport(TestCase): mocked_manager = MagicMock() # WHEN: An importer object is created - importer = SongShowPlusImport(mocked_manager) + importer = SongShowPlusImport(mocked_manager, filenames=[]) # THEN: The importer object should not be None self.assertIsNotNone(importer, 'Import should not be none') @@ -85,7 +85,7 @@ class TestSongShowPlusImport(TestCase): with patch('openlp.plugins.songs.lib.songshowplusimport.SongImport'): mocked_manager = MagicMock() mocked_import_wizard = MagicMock() - importer = SongShowPlusImport(mocked_manager) + importer = SongShowPlusImport(mocked_manager, filenames=[]) importer.import_wizard = mocked_import_wizard importer.stop_import_flag = True @@ -106,7 +106,7 @@ class TestSongShowPlusImport(TestCase): with patch('openlp.plugins.songs.lib.songshowplusimport.SongImport'): mocked_manager = MagicMock() mocked_import_wizard = MagicMock() - importer = SongShowPlusImport(mocked_manager) + importer = SongShowPlusImport(mocked_manager, filenames=[]) importer.import_wizard = mocked_import_wizard importer.stop_import_flag = True @@ -126,7 +126,7 @@ class TestSongShowPlusImport(TestCase): # GIVEN: A mocked out SongImport class, and a mocked out "manager" with patch('openlp.plugins.songs.lib.songshowplusimport.SongImport'): mocked_manager = MagicMock() - importer = SongShowPlusImport(mocked_manager) + importer = SongShowPlusImport(mocked_manager, filenames=[]) # WHEN: Supplied with the following arguments replicating verses being added test_values = [('Verse 1', VerseType.tags[VerseType.Verse] + '1'), @@ -153,7 +153,7 @@ class TestSongShowPlusImport(TestCase): # GIVEN: A mocked out SongImport class, and a mocked out "manager" with patch('openlp.plugins.songs.lib.songshowplusimport.SongImport'): mocked_manager = MagicMock() - importer = SongShowPlusImport(mocked_manager) + importer = SongShowPlusImport(mocked_manager, filenames=[]) # WHEN: Supplied with the following arguments replicating a verse order being added test_values = [('Verse 1', VerseType.tags[VerseType.Verse] + '1'), diff --git a/tests/helpers/songfileimport.py b/tests/helpers/songfileimport.py index 2ffecb11a..12754f55a 100644 --- a/tests/helpers/songfileimport.py +++ b/tests/helpers/songfileimport.py @@ -89,7 +89,7 @@ class SongImportTestHelper(TestCase): """ Import the given file and check that it has imported correctly """ - importer = self.importer_class(self.mocked_manager) + importer = self.importer_class(self.mocked_manager, filenames=[source_file_name]) importer.import_wizard = self.mocked_import_wizard importer.stop_import_flag = False importer.topics = []