openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #21767
[Merge] lp:~whydoubt/openlp/fix_platform_tests into lp:openlp
Jeffrey Smith has proposed merging lp:~whydoubt/openlp/fix_platform_tests into lp:openlp.
Requested reviews:
OpenLP Core (openlp-core)
For more details, see:
https://code.launchpad.net/~whydoubt/openlp/fix_platform_tests/+merge/185616
Handle tests with platform-dependent behavior carefully.
Testing platform-specific behavior on a different platform is of limited value.
For tests that only work on specific platforms, mark the test to be skipped on other platforms.
For tests that should behave the same on all platforms, consolidate platform-specific tests.
--
https://code.launchpad.net/~whydoubt/openlp/fix_platform_tests/+merge/185616
Your team OpenLP Core is requested to review the proposed merge of lp:~whydoubt/openlp/fix_platform_tests into lp:openlp.
=== modified file 'tests/functional/openlp_core_utils/test_utils.py'
--- tests/functional/openlp_core_utils/test_utils.py 2013-09-11 15:09:36 +0000
+++ tests/functional/openlp_core_utils/test_utils.py 2013-09-14 03:15:27 +0000
@@ -105,33 +105,14 @@
# THEN: The file name should be cleaned.
assert result == wanted_name, 'The file name should not contain any special characters.'
- def get_locale_key_windows_test(self):
- """
- Test the get_locale_key(string) function
- """
- with patch('openlp.core.utils.languagemanager.LanguageManager.get_language') as mocked_get_language, \
- patch('openlp.core.utils.os') as mocked_os:
- # GIVEN: The language is German
- # 0x00C3 (A with diaresis) should be sorted as "A". 0x00DF (sharp s) should be sorted as "ss".
- mocked_get_language.return_value = 'de'
- mocked_os.name = 'nt'
- unsorted_list = ['Auszug', 'Aushang', '\u00C4u\u00DFerung']
- # WHEN: We sort the list and use get_locale_key() to generate the sorting keys
- # THEN: We get a properly sorted list
- test_passes = sorted(unsorted_list, key=get_locale_key) == ['Aushang', '\u00C4u\u00DFerung', 'Auszug']
- assert test_passes, 'Strings should be sorted properly'
-
- def get_locale_key_linux_test(self):
-
- """
- Test the get_locale_key(string) function
- """
- with patch('openlp.core.utils.languagemanager.LanguageManager.get_language') as mocked_get_language, \
- patch('openlp.core.utils.os.name') as mocked_os:
- # GIVEN: The language is German
- # 0x00C3 (A with diaresis) should be sorted as "A". 0x00DF (sharp s) should be sorted as "ss".
- mocked_get_language.return_value = 'de'
- mocked_os.name = 'linux'
+ def get_locale_key_test(self):
+ """
+ Test the get_locale_key(string) function
+ """
+ with patch('openlp.core.utils.languagemanager.LanguageManager.get_language') as mocked_get_language:
+ # GIVEN: The language is German
+ # 0x00C3 (A with diaresis) should be sorted as "A". 0x00DF (sharp s) should be sorted as "ss".
+ mocked_get_language.return_value = 'de'
unsorted_list = ['Auszug', 'Aushang', '\u00C4u\u00DFerung']
# WHEN: We sort the list and use get_locale_key() to generate the sorting keys
# THEN: We get a properly sorted list
=== modified file 'tests/functional/openlp_plugins/songs/test_worshipcenterproimport.py'
--- tests/functional/openlp_plugins/songs/test_worshipcenterproimport.py 2013-08-31 18:17:38 +0000
+++ tests/functional/openlp_plugins/songs/test_worshipcenterproimport.py 2013-09-14 03:15:27 +0000
@@ -5,11 +5,13 @@
This module contains tests for the WorshipCenter Pro song importer.
"""
-from unittest import TestCase
+from unittest import TestCase, skipIf
from mock import patch, MagicMock
-import pyodbc
-from openlp.plugins.songs.lib.worshipcenterproimport import WorshipCenterProImport
+import os
+if os.name == 'nt':
+ import pyodbc
+ from openlp.plugins.songs.lib.worshipcenterproimport import WorshipCenterProImport
class TestRecord(object):
"""
@@ -23,22 +25,23 @@
self.Field = field
self.Value = value
-class WorshipCenterProImportLogger(WorshipCenterProImport):
- """
- This class logs changes in the title instance variable
- """
- _title_assignment_list = []
-
- def __init__(self, manager):
- WorshipCenterProImport.__init__(self, manager)
-
- @property
- def title(self):
- return self._title_assignment_list[-1]
-
- @title.setter
- def title(self, title):
- self._title_assignment_list.append(title)
+if os.name == 'nt':
+ class WorshipCenterProImportLogger(WorshipCenterProImport):
+ """
+ This class logs changes in the title instance variable
+ """
+ _title_assignment_list = []
+
+ def __init__(self, manager):
+ WorshipCenterProImport.__init__(self, manager)
+
+ @property
+ def title(self):
+ return self._title_assignment_list[-1]
+
+ @title.setter
+ def title(self, title):
+ self._title_assignment_list.append(title)
RECORDSET_TEST_DATA = [TestRecord(1, 'TITLE', 'Amazing Grace'),
@@ -98,6 +101,7 @@
('There\'s a garden where\nJesus is waiting,\nAnd He bids you to come,\nmeet Him there;\n'
'Just to bow and\nreceive a new blessing\nIn the beautiful\ngarden of prayer.')]}]
+@skipIf(os.name != 'nt', 'WorshipCenter Pro import only supported on Windows')
class TestWorshipCenterProSongImport(TestCase):
"""
Test the functions in the :mod:`worshipcenterproimport` module.
@@ -189,4 +193,4 @@
for call in verse_calls:
mocked_add_verse.assert_any_call(call)
self.assertEqual(mocked_add_verse.call_count, add_verse_call_count,
- 'Incorrect number of calls made to addVerse')
\ No newline at end of file
+ 'Incorrect number of calls made to addVerse')
Follow ups