openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #32539
[Merge] lp:~trb143/openlp/asserts2 into lp:openlp
Tim Bentley has proposed merging lp:~trb143/openlp/asserts2 into lp:openlp.
Requested reviews:
OpenLP Core (openlp-core)
For more details, see:
https://code.launchpad.net/~trb143/openlp/asserts2/+merge/335571
All tests migrated to assert from self.assert except projection
All tests pass on linux with pytest and nose2
lp:~trb143/openlp/asserts2 (revision 2838)
https://ci.openlp.io/job/Branch-01-Pull/2374/ [SUCCESS]
https://ci.openlp.io/job/Branch-02-Functional-Tests/2275/ [SUCCESS]
https://ci.openlp.io/job/Branch-03-Interface-Tests/2134/ [SUCCESS]
https://ci.openlp.io/job/Branch-04a-Code_Analysis/1460/ [SUCCESS]
https://ci.openlp.io/job/Branch-04b-Test_Coverage/1273/ [SUCCESS]
https://ci.openlp.io/job/Branch-04c-Code_Analysis2/403/ [SUCCESS]
--
Your team OpenLP Core is requested to review the proposed merge of lp:~trb143/openlp/asserts2 into lp:openlp.
=== modified file 'tests/functional/openlp_core/lib/test_image_manager.py'
--- tests/functional/openlp_core/lib/test_image_manager.py 2017-12-18 17:10:04 +0000
+++ tests/functional/openlp_core/lib/test_image_manager.py 2017-12-23 09:39:35 +0000
@@ -72,13 +72,13 @@
image = self.image_manager.get_image(full_path, 'church.jpg')
# THEN returned record is a type of image
- self.assertEqual(isinstance(image, QtGui.QImage), True, 'The returned object should be a QImage')
+ assert isinstance(image, QtGui.QImage), 'The returned object should be a QImage'
# WHEN: The image bytes are requested.
byte_array = self.image_manager.get_image_bytes(full_path, 'church.jpg')
# THEN: Type should be a str.
- self.assertEqual(isinstance(byte_array, str), True, 'The returned object should be a str')
+ assert isinstance(byte_array, str), 'The returned object should be a str'
# WHEN the image is retrieved has not been loaded
# THEN a KeyError is thrown
@@ -104,14 +104,14 @@
self.image_manager.add_image(full_path, 'church.jpg', None, 100, 100)
# THEN: the cache should contain two pictures
- self.assertEqual(len(self.image_manager._cache), 2,
- 'Image manager should consider two dimensions of the same picture as different')
+ assert len(self.image_manager._cache) == 2, \
+ 'Image manager should consider two dimensions of the same picture as different'
# WHEN: adding the same image with first dimensions
self.image_manager.add_image(full_path, 'church.jpg', None, 80, 80)
# THEN: the cache should still contain only two pictures
- self.assertEqual(len(self.image_manager._cache), 2, 'Same dimensions should not be added again')
+ assert len(self.image_manager._cache) == 2, 'Same dimensions should not be added again'
# WHEN: calling with correct image, but wrong dimensions
with self.assertRaises(KeyError) as context:
=== modified file 'tests/functional/openlp_core/lib/test_lib.py'
--- tests/functional/openlp_core/lib/test_lib.py 2017-12-18 17:10:04 +0000
+++ tests/functional/openlp_core/lib/test_lib.py 2017-12-23 09:39:35 +0000
@@ -291,7 +291,7 @@
icon = create_thumb(image_path, thumb_path, size=thumb_size)
# THEN: Check if the thumb was created and scaled to the given size.
- self.assertTrue(thumb_path.exists(), 'Test was not ran, because the thumb already exists')
+ assert thumb_path.exists() is True, 'Test was not ran, because the thumb already exists'
assert isinstance(icon, QtGui.QIcon), 'The icon should be a QIcon'
assert icon.isNull() is False, 'The icon should not be null'
assert thumb_size == QtGui.QImageReader(str(thumb_path)).size(), 'The thumb should have the given size'
@@ -325,7 +325,7 @@
icon = create_thumb(image_path, thumb_path)
# THEN: Check if the thumb was created, retaining its aspect ratio.
- self.assertTrue(thumb_path.exists(), 'Test was not ran, because the thumb already exists')
+ assert thumb_path.exists() is True, 'Test was not ran, because the thumb already exists'
assert isinstance(icon, QtGui.QIcon), 'The icon should be a QIcon'
assert icon.isNull() is False, 'The icon should not be null'
assert expected_size == QtGui.QImageReader(str(thumb_path)).size(), 'The thumb should have the given size'
@@ -430,7 +430,7 @@
icon = create_thumb(image_path, thumb_path, size=thumb_size)
# THEN: Check if the thumb was created, retaining its aspect ratio.
- self.assertTrue(thumb_path.exists(), 'Test was not ran, because the thumb already exists')
+ assert thumb_path.exists() is True, 'Test was not ran, because the thumb already exists'
assert isinstance(icon, QtGui.QIcon), 'The icon should be a QIcon'
assert icon.isNull() is False, 'The icon should not be null'
assert expected_size == QtGui.QImageReader(str(thumb_path)).size(), 'The thumb should have the given size'
@@ -468,7 +468,7 @@
icon = create_thumb(image_path, thumb_path, size=None)
# THEN: Check if the thumb was created with aspect ratio of 1.
- self.assertTrue(thumb_path.exists(), 'Test was not ran, because the thumb already exists')
+ assert thumb_path.exists() is True, 'Test was not ran, because the thumb already exists'
assert isinstance(icon, QtGui.QIcon), 'The icon should be a QIcon'
assert icon.isNull() is False, 'The icon should not be null'
assert expected_size_1 == QtGui.QImageReader(str(thumb_path)).size(), 'The thumb should have the given size'
@@ -789,7 +789,7 @@
ret = compare_chord_lyric(chord, lyrics)
# THEN: The returned value should 0 because the lyric is longer than the chord
- self.assertEquals(0, ret, 'The returned value should 0 because the lyric is longer than the chord')
+ assert 0 == ret, 'The returned value should 0 because the lyric is longer than the chord'
def test_compare_chord_lyric_long_chord(self):
"""
=== modified file 'tests/functional/openlp_core/lib/test_path.py'
--- tests/functional/openlp_core/lib/test_path.py 2017-08-25 20:03:25 +0000
+++ tests/functional/openlp_core/lib/test_path.py 2017-12-23 09:39:35 +0000
@@ -52,7 +52,7 @@
result = path_to_str(None)
# THEN: `path_to_str` should return an empty string
- self.assertEqual(result, '')
+ assert result == ''
def test_path_to_str_path_object(self):
"""
@@ -63,7 +63,7 @@
result = path_to_str(Path('test/path'))
# THEN: `path_to_str` should return a string representation of the Path object
- self.assertEqual(result, os.path.join('test', 'path'))
+ assert result == os.path.join('test', 'path')
def test_str_to_path_type_error(self):
"""
@@ -84,4 +84,4 @@
result = str_to_path('')
# THEN: `path_to_str` should return None
- self.assertEqual(result, None)
+ assert result is None
=== modified file 'tests/functional/openlp_core/test_app.py'
--- tests/functional/openlp_core/test_app.py 2017-12-19 19:22:47 +0000
+++ tests/functional/openlp_core/test_app.py 2017-12-23 09:39:35 +0000
@@ -310,7 +310,7 @@
# THEN:
assert result is True, "The method should have returned True."
- # self.assertFalse(self.openlp.main_window.isMinimized())
+ # assert self.openlp.main_window.isMinimized() is False
@patch('openlp.core.app.get_version')
@patch('openlp.core.app.QtWidgets.QMessageBox.question')
=== modified file 'tests/functional/openlp_core/ui/test_mainwindow.py'
--- tests/functional/openlp_core/ui/test_mainwindow.py 2017-12-20 20:38:43 +0000
+++ tests/functional/openlp_core/ui/test_mainwindow.py 2017-12-23 09:39:35 +0000
@@ -117,8 +117,8 @@
# WHEN no changes are made to the service
# THEN the main window's title shoud be the same as the OpenLP string in the UiStrings class
- self.assertEqual(self.main_window.windowTitle(), UiStrings().OpenLP,
- 'The main window\'s title should be the same as the OpenLP string in UiStrings class')
+ assert self.main_window.windowTitle() == UiStrings().OpenLP, \
+ 'The main window\'s title should be the same as the OpenLP string in UiStrings class'
def test_set_service_modifed(self):
"""
@@ -204,7 +204,7 @@
self.main_window.on_search_shortcut_triggered()
# THEN: The media manager dock is made visible
- self.assertEqual(0, mocked_media_manager_dock.setVisible.call_count)
+ assert 0 == mocked_media_manager_dock.setVisible.call_count
mocked_widget.on_focus.assert_called_with()
@patch('openlp.core.ui.mainwindow.FirstTimeForm')
=== modified file 'tests/functional/openlp_plugins/alerts/test_manager.py'
--- tests/functional/openlp_plugins/alerts/test_manager.py 2017-04-24 05:17:55 +0000
+++ tests/functional/openlp_plugins/alerts/test_manager.py 2017-12-23 09:39:35 +0000
@@ -51,7 +51,7 @@
alert_manager.alert_text('')
# THEN: the display should not have been triggered
- self.assertFalse(alert_manager.display_alert.called, 'The Alert should not have been called')
+ assert alert_manager.display_alert.called is False, 'The Alert should not have been called'
def test_trigger_message_text(self):
"""
@@ -65,7 +65,7 @@
alert_manager.alert_text(['This is a string'])
# THEN: the display should have been triggered
- self.assertTrue(alert_manager.display_alert.called, 'The Alert should have been called')
+ assert alert_manager.display_alert.called is True, 'The Alert should have been called'
def test_line_break_message_text(self):
"""
@@ -79,5 +79,5 @@
alert_manager.alert_text(['This is \n a string'])
# THEN: the display should have been triggered
- self.assertTrue(alert_manager.display_alert.called, 'The Alert should have been called')
+ assert alert_manager.display_alert.called is True, 'The Alert should have been called'
alert_manager.display_alert.assert_called_once_with('This is a string')
=== modified file 'tests/functional/openlp_plugins/bibles/test_bibleserver.py'
--- tests/functional/openlp_plugins/bibles/test_bibleserver.py 2017-05-30 18:42:35 +0000
+++ tests/functional/openlp_plugins/bibles/test_bibleserver.py 2017-12-23 09:39:35 +0000
@@ -75,9 +75,8 @@
self.mock_urllib.parse.quote.assert_called_once_with(b'NIV')
self.mock_get_soup_for_bible_ref.assert_called_once_with(
'http://m.bibleserver.com/overlay/selectBook?translation=NIV')
- self.assertIsNone(result,
- 'BSExtract.get_books_from_http should return None when get_soup_for_bible_ref returns a '
- 'false value')
+ assert result is None, \
+ 'BSExtract.get_books_from_http should return None when get_soup_for_bible_ref returns a false value'
def test_get_books_from_http_no_content(self):
"""
@@ -106,9 +105,8 @@
self.mock_soup.find.assert_called_once_with('ul')
self.mock_log.error.assert_called_once_with('No books found in the Bibleserver response.')
self.mock_send_error_message.assert_called_once_with('parse')
- self.assertIsNone(result,
- 'BSExtract.get_books_from_http should return None when get_soup_for_bible_ref returns a '
- 'false value')
+ assert result is None, \
+ 'BSExtract.get_books_from_http should return None when get_soup_for_bible_ref returns a false value'
def test_get_books_from_http_content(self):
"""
@@ -138,6 +136,6 @@
self.mock_urllib.parse.quote.assert_called_once_with(b'NIV')
self.mock_get_soup_for_bible_ref.assert_called_once_with(
'http://m.bibleserver.com/overlay/selectBook?translation=NIV')
- self.assertFalse(self.mock_log.error.called, 'log.error should not have been called')
- self.assertFalse(self.mock_send_error_message.called, 'send_error_message should not have been called')
- self.assertEqual(result, ['Genesis', 'Leviticus'])
+ assert self.mock_log.error.called is False, 'log.error should not have been called'
+ assert self.mock_send_error_message.called is False, 'send_error_message should not have been called'
+ assert result == ['Genesis', 'Leviticus']
=== modified file 'tests/functional/openlp_plugins/bibles/test_csvimport.py'
--- tests/functional/openlp_plugins/bibles/test_csvimport.py 2017-11-06 22:41:36 +0000
+++ tests/functional/openlp_plugins/bibles/test_csvimport.py 2017-12-23 09:39:35 +0000
@@ -64,9 +64,9 @@
CSVBible(mocked_manager, path='.', name='.', books_path=Path('books.csv'), verse_path=Path('verse.csv'))
# THEN: The importer should be an instance of BibleImport
- self.assertIsInstance(importer, BibleImport)
- self.assertEqual(importer.books_path, Path('books.csv'))
- self.assertEqual(importer.verses_path, Path('verse.csv'))
+ assert isinstance(importer, BibleImport)
+ assert importer.books_path == Path('books.csv')
+ assert importer.verses_path == Path('verse.csv')
def test_book_namedtuple(self):
"""
@@ -77,10 +77,10 @@
result = Book('id', 'testament_id', 'name', 'abbreviation')
# THEN: The attributes should match up with the data we used
- self.assertEqual(result.id, 'id')
- self.assertEqual(result.testament_id, 'testament_id')
- self.assertEqual(result.name, 'name')
- self.assertEqual(result.abbreviation, 'abbreviation')
+ assert result.id == 'id'
+ assert result.testament_id == 'testament_id'
+ assert result.name == 'name'
+ assert result.abbreviation == 'abbreviation'
def test_verse_namedtuple(self):
"""
@@ -91,10 +91,10 @@
result = Verse('book_id_name', 'chapter_number', 'number', 'text')
# THEN: The attributes should match up with the data we used
- self.assertEqual(result.book_id_name, 'book_id_name')
- self.assertEqual(result.chapter_number, 'chapter_number')
- self.assertEqual(result.number, 'number')
- self.assertEqual(result.text, 'text')
+ assert result.book_id_name == 'book_id_name'
+ assert result.chapter_number == 'chapter_number'
+ assert result.number == 'number'
+ assert result.text == 'text'
def test_get_book_name_id(self):
"""
@@ -109,7 +109,7 @@
actual_result = CSVBible.get_book_name(name, books)
# THEN: get_book_name() should return the book name associated with that id from the books dictionary
- self.assertEqual(actual_result, expected_result)
+ assert actual_result == expected_result
def test_get_book_name(self):
"""
@@ -124,7 +124,7 @@
actual_result = CSVBible.get_book_name(name, books)
# THEN: get_book_name() should return the input
- self.assertEqual(actual_result, expected_result)
+ assert actual_result == expected_result
def test_parse_csv_file(self):
"""
@@ -144,8 +144,8 @@
result = CSVBible.parse_csv_file(Path('file.csv'), TestTuple)
# THEN: A list of TestTuple instances with the parsed data should be returned
- self.assertEqual(result, [TestTuple('1', 'Line 1', 'Data 1'), TestTuple('2', 'Line 2', 'Data 2'),
- TestTuple('3', 'Line 3', 'Data 3')])
+ assert result == [TestTuple('1', 'Line 1', 'Data 1'), TestTuple('2', 'Line 2', 'Data 2'),
+ TestTuple('3', 'Line 3', 'Data 3')]
mocked_open.assert_called_once_with('r', encoding='utf-8', newline='')
mocked_reader.assert_called_once_with(ANY, delimiter=',', quotechar='"')
@@ -162,7 +162,7 @@
# THEN: A ValidationError should be raised
with self.assertRaises(ValidationError) as context:
CSVBible.parse_csv_file(Path('file.csv'), None)
- self.assertEqual(context.exception.msg, 'Parsing "file.csv" failed')
+ assert context.exception.msg == 'Parsing "file.csv" failed'
def test_parse_csv_file_csverror(self):
"""
@@ -178,7 +178,7 @@
# THEN: A ValidationError should be raised
with self.assertRaises(ValidationError) as context:
CSVBible.parse_csv_file(Path('file.csv'), None)
- self.assertEqual(context.exception.msg, 'Parsing "file.csv" failed')
+ assert context.exception.msg == 'Parsing "file.csv" failed'
def test_process_books_stopped_import(self):
"""
@@ -197,8 +197,8 @@
result = importer.process_books(['Book 1'])
# THEN: increment_progress_bar should not be called and the return value should be an empty dictionary
- self.assertFalse(importer.wizard.increment_progress_bar.called)
- self.assertEqual(result, {})
+ assert importer.wizard.increment_progress_bar.called is False
+ assert result == {}
def test_process_books(self):
"""
@@ -222,9 +222,9 @@
# THEN: translate and find_and_create_book should have been called with both book names.
# The returned data should be a dictionary with both song's id and names.
- self.assertEqual(importer.find_and_create_book.mock_calls,
- [call('1. Mosebog', 2, 10), call('2. Mosebog', 2, 10)])
- self.assertDictEqual(result, {1: '1. Mosebog', 2: '2. Mosebog'})
+ assert importer.find_and_create_book.mock_calls == \
+ [call('1. Mosebog', 2, 10), call('2. Mosebog', 2, 10)]
+ assert result == {1: '1. Mosebog', 2: '2. Mosebog'}
def test_process_verses_stopped_import(self):
"""
@@ -244,8 +244,8 @@
result = importer.process_verses(['Dummy Verse'], [])
# THEN: get_book_name should not be called and the return value should be None
- self.assertFalse(importer.get_book_name.called)
- self.assertIsNone(result)
+ assert importer.get_book_name.called is False
+ assert result is None
def test_process_verses_successful(self):
"""
@@ -272,13 +272,13 @@
importer.process_verses(verses, books)
# THEN: create_verse is called with the test data
- self.assertEqual(importer.get_book_name.mock_calls, [call(1, books), call(1, books)])
+ assert importer.get_book_name.mock_calls == [call(1, books), call(1, books)]
importer.get_book.assert_called_once_with('1. Mosebog')
- self.assertEqual(importer.session.commit.call_count, 2)
- self.assertEqual(importer.create_verse.mock_calls,
- [call('1', 1, 1, 'I Begyndelsen skabte Gud Himmelen og Jorden.'),
- call('1', 1, 2, 'Og Jorden var øde og tom, og der var Mørke over Verdensdybet. '
- 'Men Guds Ånd svævede over Vandene.')])
+ assert importer.session.commit.call_count == 2
+ assert importer.create_verse.mock_calls == \
+ [call('1', 1, 1, 'I Begyndelsen skabte Gud Himmelen og Jorden.'),
+ call('1', 1, 2, 'Og Jorden var øde og tom, og der var Mørke over Verdensdybet. '
+ 'Men Guds Ånd svævede over Vandene.')]
def test_do_import_invalid_language_id(self):
"""
@@ -296,7 +296,7 @@
# THEN: The False should be returned.
importer.get_language.assert_called_once_with('Bible Name')
- self.assertFalse(result)
+ assert result is False
def test_do_import_success(self):
"""
@@ -320,11 +320,11 @@
# THEN: parse_csv_file should be called twice,
# and True should be returned.
- self.assertEqual(importer.parse_csv_file.mock_calls,
- [call(Path('books.csv'), Book), call(Path('verses.csv'), Verse)])
+ assert importer.parse_csv_file.mock_calls == \
+ [call(Path('books.csv'), Book), call(Path('verses.csv'), Verse)]
importer.process_books.assert_called_once_with(['Book 1'])
importer.process_verses.assert_called_once_with(['Verse 1'], ['Book 1'])
- self.assertTrue(result)
+ assert result is True
def test_file_import(self):
"""
@@ -353,7 +353,7 @@
importer.do_import()
# THEN: The create_verse() method should have been called with each verse in the file.
- self.assertTrue(importer.create_verse.called)
+ assert importer.create_verse.called is True
for verse_tag, verse_text in test_data['verses']:
importer.create_verse.assert_any_call(importer.get_book().id, 1, verse_tag, verse_text)
importer.create_book.assert_any_call('1. Mosebog', importer.get_book_ref_id_by_name(), 1)
=== modified file 'tests/functional/openlp_plugins/bibles/test_lib.py'
--- tests/functional/openlp_plugins/bibles/test_lib.py 2017-06-05 02:58:38 +0000
+++ tests/functional/openlp_plugins/bibles/test_lib.py 2017-12-23 09:39:35 +0000
@@ -59,7 +59,7 @@
_ = lib.get_reference_separator(key)
# THEN: get_reference_separator should return the correct separator
- self.assertEqual(separators[key], value)
+ assert separators[key] == value
mocked_update_reference_separators.assert_called_once_with()
def test_reference_matched_full(self):
@@ -116,13 +116,13 @@
# THEN: A match should be returned, and the book and reference should match the
# expected result
- self.assertIsNotNone(match, '{text} should provide a match'.format(text=reference_text))
- self.assertEqual(book_result, match.group('book'),
- '{text} does not provide the expected result for the book group.'
- .format(text=reference_text))
- self.assertEqual(ranges_result, match.group('ranges'),
- '{text} does not provide the expected result for the ranges group.'
- .format(text=reference_text))
+ assert match is not None, '{text} should provide a match'.format(text=reference_text)
+ assert book_result, match.group('book') == \
+ '{text} does not provide the expected result for the book group.'\
+ .format(text=reference_text)
+ assert ranges_result, match.group('ranges') == \
+ '{text} does not provide the expected result for the ranges group.' \
+ .format(text=reference_text)
def test_reference_matched_range(self):
"""
@@ -158,12 +158,12 @@
# THEN: A match should be returned, and the to/from chapter/verses should match as
# expected
- self.assertIsNotNone(match, '{text} should provide a match'.format(text=reference_text))
- self.assertEqual(match.group('from_chapter'), from_chapter)
- self.assertEqual(match.group('from_verse'), from_verse)
- self.assertEqual(match.group('range_to'), range_to)
- self.assertEqual(match.group('to_chapter'), to_chapter)
- self.assertEqual(match.group('to_verse'), to_verse)
+ assert match is not None, '{text} should provide a match'.format(text=reference_text)
+ assert match.group('from_chapter') == from_chapter
+ assert match.group('from_verse') == from_verse
+ assert match.group('range_to') == range_to
+ assert match.group('to_chapter') == to_chapter
+ assert match.group('to_verse') == to_verse
def test_reference_matched_range_separator(self):
# GIVEN: Some test data which contains different references to parse, with the expected results.
@@ -199,7 +199,7 @@
references = full_reference_match.split(reference_text)
# THEN: The list of references should be as the expected results
- self.assertEqual(references, ranges)
+ assert references == ranges
def test_search_results_creation(self):
"""
@@ -218,10 +218,10 @@
search_results = SearchResults(book, chapter, verse_list)
# THEN: It should have a book, a chapter and a verse list
- self.assertIsNotNone(search_results, 'The search_results object should not be None')
- self.assertEqual(search_results.book, book, 'The book should be "Genesis"')
- self.assertEqual(search_results.chapter, chapter, 'The chapter should be 1')
- self.assertDictEqual(search_results.verse_list, verse_list, 'The verse lists should be identical')
+ assert search_results is not None, 'The search_results object should not be None'
+ assert search_results.book == book, 'The book should be "Genesis"'
+ assert search_results.chapter == chapter, 'The chapter should be 1'
+ assert search_results.verse_list == verse_list, 'The verse lists should be identical'
def test_search_results_has_verse_list(self):
"""
@@ -234,7 +234,7 @@
has_verse_list = search_results.has_verse_list()
# THEN: It should be True
- self.assertTrue(has_verse_list, 'The SearchResults object should have a verse list')
+ assert has_verse_list is True, 'The SearchResults object should have a verse list'
def test_search_results_has_no_verse_list(self):
"""
@@ -247,4 +247,4 @@
has_verse_list = search_results.has_verse_list()
# THEN: It should be False
- self.assertFalse(has_verse_list, 'The SearchResults object should have a verse list')
+ assert has_verse_list is False, 'The SearchResults object should have a verse list'
=== modified file 'tests/functional/openlp_plugins/bibles/test_manager.py'
--- tests/functional/openlp_plugins/bibles/test_manager.py 2017-08-25 20:03:25 +0000
+++ tests/functional/openlp_plugins/bibles/test_manager.py 2017-12-23 09:39:35 +0000
@@ -63,7 +63,7 @@
# THEN: The session should have been closed and set to None, the bible should be deleted, and the result of
# the deletion returned.
- self.assertTrue(result)
+ assert result is True
mocked_close_all.assert_called_once_with()
- self.assertIsNone(mocked_bible.session)
+ assert mocked_bible.session is None
mocked_delete_file.assert_called_once_with(Path('bibles', 'KJV.sqlite'))
=== modified file 'tests/functional/openlp_plugins/bibles/test_mediaitem.py'
--- tests/functional/openlp_plugins/bibles/test_mediaitem.py 2017-10-07 07:05:07 +0000
+++ tests/functional/openlp_plugins/bibles/test_mediaitem.py 2017-12-23 09:39:35 +0000
@@ -53,9 +53,9 @@
# THEN: The expected result should be returned
if expected_result is None:
- self.assertIsNone(result, expected_result)
+ assert result is None, expected_result
else:
- self.assertEqual(result.regs, expected_result)
+ assert result.regs == expected_result
def test_get_reference_separators(self):
"""
@@ -69,7 +69,7 @@
# THEN: The result should contain the 'verse', 'range', 'list' keys and get_reference_separator should have
# been called with the expected values.
- self.assertTrue(all(key in result for key in ('verse', 'range', 'list')))
+ assert all(key in result for key in ('verse', 'range', 'list')) is True
mocked_get_reference_separator.assert_has_calls(
[call('sep_v_display'), call('sep_r_display'), call('sep_l_display')])
@@ -80,9 +80,9 @@
# GIVEN: The BibleSearch class
# WHEN: Testing its attributes
# THEN: The BibleSearch class should have the following enumrations
- self.assertTrue(hasattr(BibleSearch, 'Combined'))
- self.assertTrue(hasattr(BibleSearch, 'Reference'))
- self.assertTrue(hasattr(BibleSearch, 'Text'))
+ assert hasattr(BibleSearch, 'Combined')
+ assert hasattr(BibleSearch, 'Reference')
+ assert hasattr(BibleSearch, 'Text')
def test_bible_media_item_subclass(self):
"""
@@ -91,7 +91,7 @@
# GIVEN: The :class:`BibleMediaItem`
# WHEN: Checking if it is a subclass of MediaManagerItem
# THEN: BibleMediaItem should be a subclass of MediaManagerItem
- self.assertTrue(issubclass(BibleMediaItem, MediaManagerItem))
+ assert issubclass(BibleMediaItem, MediaManagerItem)
def test_bible_media_item_signals(self):
"""
@@ -99,10 +99,10 @@
"""
# GIVEN: The :class:`BibleMediaItem`
# THEN: The :class:`BibleMediaItem` should contain the following pyqtSignal's
- self.assertTrue(hasattr(BibleMediaItem, 'bibles_go_live'))
- self.assertTrue(hasattr(BibleMediaItem, 'bibles_add_to_service'))
- self.assertTrue(isinstance(BibleMediaItem.bibles_go_live, QtCore.pyqtSignal))
- self.assertTrue(isinstance(BibleMediaItem.bibles_add_to_service, QtCore.pyqtSignal))
+ assert hasattr(BibleMediaItem, 'bibles_go_live')
+ assert hasattr(BibleMediaItem, 'bibles_add_to_service')
+ assert isinstance(BibleMediaItem.bibles_go_live, QtCore.pyqtSignal)
+ assert isinstance(BibleMediaItem.bibles_add_to_service, QtCore.pyqtSignal)
class TestMediaItem(TestCase, TestMixin):
@@ -166,7 +166,7 @@
# GIVEN: An instance of :class:`BibleMediaItem`
# WEHN: Checking its class
# THEN: It should be a subclass of :class:`MediaManagerItem`
- self.assertTrue(isinstance(self.media_item, MediaManagerItem))
+ assert isinstance(self.media_item, MediaManagerItem)
def test_steup_item(self):
"""
@@ -193,11 +193,11 @@
self.media_item.required_icons()
# THEN: The correct icons should be set
- self.assertTrue(self.media_item.has_import_icon, 'Check that the icon is as True.')
- self.assertFalse(self.media_item.has_new_icon, 'Check that the icon is called as False.')
- self.assertTrue(self.media_item.has_edit_icon, 'Check that the icon is called as True.')
- self.assertTrue(self.media_item.has_delete_icon, 'Check that the icon is called as True.')
- self.assertFalse(self.media_item.add_to_service_item, 'Check that the icon is called as False')
+ assert self.media_item.has_import_icon is True, 'Check that the icon is as True.'
+ assert self.media_item.has_new_icon is False, 'Check that the icon is called as False.'
+ assert self.media_item.has_edit_icon is True, 'Check that the icon is called as True.'
+ assert self.media_item.has_delete_icon is True, 'Check that the icon is called as True.'
+ assert self.media_item.add_to_service_item is False, 'Check that the icon is called as False'
def test_on_focus_search_tab_visible(self):
"""
@@ -305,8 +305,8 @@
self.media_item.initialise()
# THEN: The search_edit search types should have been set.
- self.assertTrue(self.media_item.search_edit.set_search_types.called)
- self.assertFalse(self.media_item.search_edit.set_current_search_type.called)
+ assert self.media_item.search_edit.set_search_types.called is True
+ assert self.media_item.search_edit.set_current_search_type.called is False
def test_initalise_reset_search_type(self):
"""
@@ -323,7 +323,7 @@
# THEN: The search_edit search types should have been set and that the current search type should be set to
# 'Combined'
- self.assertTrue(self.media_item.search_edit.set_search_types.called)
+ assert self.media_item.search_edit.set_search_types.called is True
self.media_item.search_edit.set_current_search_type.assert_called_once_with(BibleSearch.Combined)
def test_populate_bible_combo_boxes(self):
@@ -373,7 +373,7 @@
result = self.media_item.get_common_books(self.mocked_bible_1)
# THEN: The book of the bible should be returned
- self.assertEqual(result, self.book_list_1)
+ assert result == self.book_list_1
def test_get_common_books_second_book(self):
"""
@@ -384,7 +384,7 @@
result = self.media_item.get_common_books(self.mocked_bible_1, self.mocked_bible_2)
# THEN: Only the books contained in both bibles should be returned
- self.assertEqual(result, [self.mocked_book_2, self.mocked_book_3])
+ assert result == [self.mocked_book_2, self.mocked_book_3]
def test_initialise_advanced_bible_no_bible(self):
"""
@@ -399,7 +399,7 @@
result = self.media_item.initialise_advanced_bible()
# THEN: initialise_advanced_bible should return with put calling get_common_books
- self.assertIsNone(result)
+ assert result is None
mocked_get_common_books.assert_not_called()
def test_initialise_advanced_bible_add_books_with_last_id_found(self):
@@ -515,8 +515,8 @@
self.media_item.on_import_click()
# THEN: BibleImport wizard should have been instianted and reload_bibles should not have been called
- self.assertTrue(mocked_bible_import_form.called)
- self.assertFalse(mocked_reload_bibles.called)
+ assert mocked_bible_import_form.called is True
+ assert mocked_reload_bibles.called is False
def test_on_import_click_wizard_not_canceled(self):
"""
@@ -532,8 +532,8 @@
self.media_item.on_import_click()
# THEN: BibleImport wizard should have been instianted and reload_bibles should not have been called
- self.assertFalse(mocked_import_wizard.called)
- self.assertTrue(mocked_reload_bibles.called)
+ assert mocked_import_wizard.called is False
+ assert mocked_reload_bibles.called is True
def test_on_edit_click_no_bible(self):
"""
@@ -547,7 +547,7 @@
self.media_item.on_edit_click()
# THEN: EditBibleForm should not have been instianted
- self.assertFalse(mocked_edit_bible_form.called)
+ assert mocked_edit_bible_form.called is False
def test_on_edit_click_user_cancel_edit_form(self):
"""
@@ -565,8 +565,8 @@
self.media_item.on_edit_click()
# THEN: EditBibleForm should have been been instianted but reload_bibles should not have been called
- self.assertTrue(mocked_edit_bible_form.called)
- self.assertFalse(mocked_reload_bibles.called)
+ assert mocked_edit_bible_form.called is True
+ assert mocked_reload_bibles.called is False
def test_on_edit_click_user_accepts_edit_form(self):
"""
@@ -585,8 +585,8 @@
self.media_item.on_edit_click()
# THEN: EditBibleForm should have been been instianted and reload_bibles should have been called
- self.assertTrue(mocked_edit_bible_form.called)
- self.assertTrue(mocked_reload_bibles.called)
+ assert mocked_edit_bible_form.called is True
+ assert mocked_reload_bibles.called is True
def test_on_delete_click_no_bible(self):
"""
@@ -600,7 +600,7 @@
self.media_item.on_delete_click()
# THEN: QMessageBox.question should not have been called
- self.assertFalse(mocked_qmessage_box.question.called)
+ assert mocked_qmessage_box.question.called is False
def test_on_delete_click_response_no(self):
"""
@@ -615,8 +615,8 @@
self.media_item.on_delete_click()
# THEN: QMessageBox.question should have been called, but the delete_bible should not have been called
- self.assertTrue(mocked_qmessage_box.called)
- self.assertFalse(self.mocked_plugin.manager.delete_bible.called)
+ assert mocked_qmessage_box.called is True
+ assert self.mocked_plugin.manager.delete_bible.called is False
def test_on_delete_click_response_yes(self):
"""
@@ -632,8 +632,8 @@
self.media_item.on_delete_click()
# THEN: QMessageBox.question should and delete_bible should not have been called
- self.assertTrue(mocked_qmessage_box.called)
- self.assertTrue(self.mocked_plugin.manager.delete_bible.called)
+ assert mocked_qmessage_box.called is True
+ assert self.mocked_plugin.manager.delete_bible.called is True
def test_on_search_tab_bar_current_changed_search_tab_selected(self):
"""
@@ -711,8 +711,8 @@
self.media_item.on_clear_button_clicked()
# THEN: The list_view and the search_edit should be cleared
- self.assertEqual(self.media_item.current_results, [])
- self.assertEqual(self.media_item.list_view.takeItem.call_count, 2)
+ assert self.media_item.current_results == []
+ assert self.media_item.list_view.takeItem.call_count == 2
self.media_item.list_view.row.assert_has_calls([call('Some'), call('Results')])
def test_on_save_results_button_clicked(self):
@@ -733,7 +733,7 @@
# THEN: The selected results in the list_view should be added to the 'saved_results' list. And the saved_tab
# total should be updated.
- self.assertEqual(self.media_item.saved_results, ['R1', 'R2', 'R3'])
+ assert self.media_item.saved_results == ['R1', 'R2', 'R3']
mocked_on_results_view_tab_total_update.assert_called_once_with(ResultsTab.Saved)
def test_on_style_combo_box_changed(self):
@@ -746,8 +746,8 @@
# WHEN: Calling on_style_combo_box_index_changed
self.media_item.on_style_combo_box_index_changed(2)
- # THEN: The layput_style settimg should have been set
- self.assertEqual(self.media_item.settings.layout_style, 2)
+ # THEN: The layout_style setting should have been set
+ assert self.media_item.settings.layout_style, 2
self.media_item.settings.layout_style_combo_box.setCurrentIndex.assert_called_once_with(2)
self.mocked_settings_instance.setValue.assert_called_once_with('bibles/verse layout style', 2)
@@ -763,9 +763,9 @@
# WHEN: Calling on_version_combo_box_index_changed
self.media_item.on_version_combo_box_index_changed()
- # THEN: The vesion should be saved to settings and the 'select tab' should be initialised
- self.assertFalse(self.mocked_settings_instance.setValue.called)
- self.assertTrue(self.media_item.initialise_advanced_bible.called)
+ # THEN: The version should be saved to settings and the 'select tab' should be initialised
+ assert self.mocked_settings_instance.setValue.called is False
+ assert self.media_item.initialise_advanced_bible.called is True
def test_on_version_combo_box_index_changed_bible_selected(self):
"""
@@ -781,9 +781,9 @@
# WHEN: Calling on_version_combo_box_index_changed
self.media_item.on_version_combo_box_index_changed()
- # THEN: The vesion should be saved to settings and the 'select tab' should be initialised
+ # THEN: The version should be saved to settings and the 'select tab' should be initialised
self.mocked_settings_instance.setValue.assert_called_once_with('bibles/primary bible', 'ABC')
- self.assertTrue(self.media_item.initialise_advanced_bible.called)
+ assert self.media_item.initialise_advanced_bible.called is True
def test_on_second_combo_box_index_changed_mode_not_changed(self):
"""
@@ -798,15 +798,15 @@
patch('openlp.plugins.bibles.lib.mediaitem.critical_error_message_box') \
as mocked_critical_error_message_box:
- # WHEN: The previously selected bible is one bible and the new selection is annother bible
+ # WHEN: The previously selected bible is one bible and the new selection is another bible
self.media_item.second_bible = self.mocked_bible_1
self.media_item.second_combo_box = MagicMock(**{'currentData.return_value': self.mocked_bible_2})
self.media_item.on_second_combo_box_index_changed(5)
# THEN: The new bible should now be the current bible
- self.assertFalse(mocked_critical_error_message_box.called)
+ assert mocked_critical_error_message_box.called is False
self.media_item.style_combo_box.setEnabled.assert_called_once_with(False)
- self.assertEqual(self.media_item.second_bible, self.mocked_bible_2)
+ assert self.media_item.second_bible == self.mocked_bible_2
def test_on_second_combo_box_index_changed_single_to_dual_user_abort(self):
"""
@@ -828,11 +828,11 @@
self.media_item.saved_results = ['saved_results']
self.media_item.on_second_combo_box_index_changed(5)
- # THEN: The list_view should be cleared and the currently selected bible should not be channged
- self.assertTrue(mocked_critical_error_message_box.called)
- self.assertTrue(self.media_item.second_combo_box.setCurrentIndex.called)
- self.assertFalse(self.media_item.style_combo_box.setEnabled.called)
- self.assertEqual(self.media_item.second_bible, None)
+ # THEN: The list_view should be cleared and the currently selected bible should not be changed
+ assert mocked_critical_error_message_box.called is True
+ assert self.media_item.second_combo_box.setCurrentIndex.called is True
+ assert self.media_item.style_combo_box.setEnabled.called is False
+ assert self.media_item.second_bible is None
def test_on_second_combo_box_index_changed_single_to_dual(self):
"""
@@ -857,10 +857,10 @@
self.media_item.on_second_combo_box_index_changed(5)
# THEN: The selected bible should be set as the current bible
- self.assertTrue(mocked_critical_error_message_box.called)
+ assert mocked_critical_error_message_box.called is True
self.media_item.style_combo_box.setEnabled.assert_called_once_with(False)
- self.assertTrue(mocked_initialise_advanced_bible.called)
- self.assertEqual(self.media_item.second_bible, self.mocked_bible_1)
+ assert mocked_initialise_advanced_bible.called is True
+ assert self.media_item.second_bible == self.mocked_bible_1
def test_on_second_combo_box_index_changed_dual_to_single(self):
"""
@@ -884,10 +884,10 @@
self.media_item.on_second_combo_box_index_changed(0)
# THEN: The selected bible should be set as the current bible
- self.assertTrue(mocked_critical_error_message_box.called)
+ assert mocked_critical_error_message_box.called is True
self.media_item.style_combo_box.setEnabled.assert_called_once_with(True)
- self.assertFalse(mocked_initialise_advanced_bible.called)
- self.assertEqual(self.media_item.second_bible, None)
+ assert mocked_initialise_advanced_bible.called is False
+ assert self.media_item.second_bible is None
def test_on_advanced_book_combo_box(self):
"""
@@ -907,7 +907,7 @@
# THEN: The user should be informed that the bible cannot be used and the search button should be disabled
self.mocked_plugin.manager.get_book_by_id.assert_called_once_with('Bible 1', 2)
self.media_item.search_button.setEnabled.assert_called_once_with(False)
- self.assertTrue(mocked_critical_error_message_box.called)
+ assert mocked_critical_error_message_box.called is True
def test_on_advanced_book_combo_box_set_up_comboboxes(self):
"""
@@ -930,7 +930,7 @@
# THEN: The verse selection combobox's should be set up
self.mocked_plugin.manager.get_book_by_id.assert_called_once_with('Bible 1', 2)
self.media_item.search_button.setEnabled.assert_called_once_with(True)
- self.assertEqual(mocked_adjust_combo_box.call_count, 4)
+ assert mocked_adjust_combo_box.call_count == 4
def test_on_from_chapter_activated_invalid_to_chapter(self):
"""
@@ -951,9 +951,9 @@
self.media_item.on_from_chapter_activated()
# THEN: The to_verse and to_chapter comboboxes should be updated appropriately
- self.assertEqual(mocked_adjust_combo_box.call_args_list, [
+ assert mocked_adjust_combo_box.call_args_list == [
call(1, 20, self.media_item.from_verse), call(1, 20, self.media_item.to_verse, False),
- call(10, 25, self.media_item.to_chapter, False)])
+ call(10, 25, self.media_item.to_chapter, False)]
def test_on_from_chapter_activated_same_chapter(self):
"""
@@ -974,9 +974,9 @@
self.media_item.on_from_chapter_activated()
# THEN: The to_verse and to_chapter comboboxes should be updated appropriately
- self.assertEqual(mocked_adjust_combo_box.call_args_list, [
+ assert mocked_adjust_combo_box.call_args_list == [
call(1, 20, self.media_item.from_verse), call(1, 20, self.media_item.to_verse, True),
- call(5, 25, self.media_item.to_chapter, False)])
+ call(5, 25, self.media_item.to_chapter, False)]
def test_on_from_chapter_activated_lower_chapter(self):
"""
@@ -996,8 +996,8 @@
self.media_item.on_from_chapter_activated()
# THEN: The to_verse and to_chapter comboboxes should be updated appropriately
- self.assertEqual(mocked_adjust_combo_box.call_args_list, [
- call(1, 20, self.media_item.from_verse), call(5, 25, self.media_item.to_chapter, True)])
+ assert mocked_adjust_combo_box.call_args_list == [
+ call(1, 20, self.media_item.from_verse), call(5, 25, self.media_item.to_chapter, True)]
def test_on_from_verse(self):
"""
@@ -1012,7 +1012,7 @@
self.media_item.on_from_verse()
# THEN: select_book_combo_box.currentData should nto be called
- self.assertFalse(self.media_item.select_book_combo_box.currentData.called)
+ assert self.media_item.select_book_combo_box.currentData.called is False
def test_on_from_verse_equal(self):
"""
@@ -1107,8 +1107,8 @@
# THEN: The combo_box should be cleared, and new items added
mocked_combo_box.clear.assert_called_once_with()
- self.assertEqual(mocked_combo_box.addItem.call_args_list,
- [call('10', 10), call('11', 11), call('12', 12), call('13', 13)])
+ assert mocked_combo_box.addItem.call_args_list == \
+ [call('10', 10), call('11', 11), call('12', 12), call('13', 13)]
def test_adjust_combo_box_restore_found(self):
"""
@@ -1123,8 +1123,8 @@
# THEN: The combo_box should be cleared, and new items added. Finally the previously selected item should be
# reselected
mocked_combo_box.clear.assert_called_once_with()
- self.assertEqual(mocked_combo_box.addItem.call_args_list,
- [call('10', 10), call('11', 11), call('12', 12), call('13', 13)])
+ assert mocked_combo_box.addItem.call_args_list == \
+ [call('10', 10), call('11', 11), call('12', 12), call('13', 13)]
mocked_combo_box.setCurrentIndex.assert_called_once_with(2)
def test_adjust_combo_box_restore_not_found(self):
@@ -1140,8 +1140,8 @@
# THEN: The combo_box should be cleared, and new items added. Finally the first item should be selected
mocked_combo_box.clear.assert_called_once_with()
- self.assertEqual(mocked_combo_box.addItem.call_args_list,
- [call('10', 10), call('11', 11), call('12', 12), call('13', 13)])
+ assert mocked_combo_box.addItem.call_args_list == \
+ [call('10', 10), call('11', 11), call('12', 12), call('13', 13)]
mocked_combo_box.setCurrentIndex.assert_called_once_with(0)
def test_on_search_button_no_bible(self):
@@ -1154,7 +1154,7 @@
self.media_item.on_search_button_clicked()
# THEN: The user should be informed that there are no bibles selected
- self.assertEqual(self.mocked_main_window.information_message.call_count, 1)
+ assert self.mocked_main_window.information_message.call_count == 1
def test_on_search_button_search_tab(self):
"""
@@ -1207,7 +1207,7 @@
self.media_item.select_search()
# THEN: reference_search should only be called once
- self.assertEqual(self.mocked_plugin.manager.get_verses.call_count, 1)
+ assert self.mocked_plugin.manager.get_verses.call_count == 1
mocked_display_results.assert_called_once_with()
def test_select_search_dual_bibles(self):
@@ -1228,7 +1228,7 @@
self.media_item.select_search()
# THEN: reference_search should be called twice
- self.assertEqual(self.mocked_plugin.manager.get_verses.call_count, 2)
+ assert self.mocked_plugin.manager.get_verses.call_count == 2
mocked_display_results.assert_called_once_with()
def test_text_reference_search_single_bible(self):
@@ -1244,7 +1244,7 @@
self.media_item.text_reference_search('Search Text')
# THEN: reference_search should only be called once
- self.assertEqual(self.mocked_plugin.manager.get_verses.call_count, 1)
+ assert self.mocked_plugin.manager.get_verses.call_count == 1
mocked_display_results.assert_called_once_with()
def text_reference_search(self, search_text, search_while_type=False):
@@ -1272,7 +1272,7 @@
self.media_item.text_reference_search('Search Text')
# THEN: reference_search should only be called once
- self.assertEqual(self.mocked_plugin.manager.get_verses.call_count, 1)
+ assert self.mocked_plugin.manager.get_verses.call_count == 1
mocked_display_results.assert_called_once_with()
def test_text_reference_search_dual_bible(self):
@@ -1288,7 +1288,7 @@
self.media_item.text_reference_search('Search Text')
# THEN: reference_search should be called twice
- self.assertEqual(self.mocked_plugin.manager.get_verses.call_count, 2)
+ assert self.mocked_plugin.manager.get_verses.call_count == 2
mocked_display_results.assert_called_once_with()
def test_on_text_search_single_bible(self):
@@ -1305,7 +1305,7 @@
self.media_item.on_text_search('Search Text')
# THEN: The search results should be the same as those returned by plugin.manager.verse_search
- self.assertEqual(self.media_item.search_results, ['results', 'list'])
+ assert self.media_item.search_results == ['results', 'list']
mocked_display_results.assert_called_once_with()
def test_on_text_search_no_results(self):
@@ -1322,7 +1322,7 @@
self.media_item.on_text_search('Search Text')
# THEN: The search results should be an empty list
- self.assertEqual(self.media_item.search_results, [])
+ assert self.media_item.search_results == []
mocked_display_results.assert_called_once_with()
def test_on_text_search_all_results_in_both_books(self):
@@ -1345,10 +1345,10 @@
self.media_item.on_text_search('Search Text')
# THEN: The search results for both bibles should be returned
- self.assertEqual(self.media_item.search_results, [mocked_verse_1, mocked_verse_2])
- self.assertEqual(self.media_item.second_search_results, [mocked_verse_1a, mocked_verse_2a])
- self.assertFalse(self.mocked_log.debug.called)
- self.assertFalse(self.mocked_main_window.information_message.called)
+ assert self.media_item.search_results == [mocked_verse_1, mocked_verse_2]
+ assert self.media_item.second_search_results == [mocked_verse_1a, mocked_verse_2a]
+ assert self.mocked_log.debug.called is False
+ assert self.mocked_main_window.information_message.called is False
mocked_display_results.assert_called_once_with()
def test_on_text_search_not_all_results_in_both_books(self):
@@ -1372,10 +1372,10 @@
# THEN: The search results included in both bibles should be returned and the user should be notified of
# the missing verses
- self.assertEqual(self.media_item.search_results, [mocked_verse_1])
- self.assertEqual(self.media_item.second_search_results, [mocked_verse_1a])
- self.assertEqual(self.mocked_log.debug.call_count, 2)
- self.assertTrue(self.mocked_main_window.information_message.called)
+ assert self.media_item.search_results == [mocked_verse_1]
+ assert self.media_item.second_search_results == [mocked_verse_1a]
+ assert self.mocked_log.debug.call_count == 2
+ assert self.mocked_main_window.information_message.called is True
mocked_display_results.assert_called_once_with()
def test_on_search_edit_text_changed_search_while_typing_disabled(self):
@@ -1391,7 +1391,7 @@
self.media_item.on_search_edit_text_changed()
# THEN: The method should not have checked if the timer is active
- self.assertFalse(self.media_item.search_timer.isActive.called)
+ assert self.media_item.search_timer.isActive.called is False
def test_on_search_edit_text_changed_search_while_typing_enabled(self):
"""
@@ -1422,7 +1422,7 @@
self.media_item.on_search_timer_timeout()
# THEN: The search_status should be set to SearchAsYouType and text_search should have been called
- self.assertEqual(self.media_item.search_status, SearchStatus.SearchAsYouType)
+ assert self.media_item.search_status == SearchStatus.SearchAsYouType
mocked_text_search.assert_called_once_with()
def test_display_results_no_results(self):
@@ -1441,7 +1441,7 @@
self.media_item.display_results()
# THEN: No items should be added to the list
- self.assertFalse(self.media_item.list_view.addItem.called)
+ assert self.media_item.list_view.addItem.called is False
def test_display_results_results(self):
"""
=== modified file 'tests/functional/openlp_plugins/bibles/test_opensongimport.py'
--- tests/functional/openlp_plugins/bibles/test_opensongimport.py 2017-11-06 22:41:36 +0000
+++ tests/functional/openlp_plugins/bibles/test_opensongimport.py 2017-12-23 09:39:35 +0000
@@ -68,7 +68,7 @@
importer = OpenSongBible(mocked_manager, path='.', name='.', file_path=None)
# THEN: The importer should be an instance of BibleDB
- self.assertIsInstance(importer, BibleImport)
+ assert isinstance(importer, BibleImport)
def test_get_text_no_text(self):
"""
@@ -81,7 +81,7 @@
result = get_text(test_data)
# THEN: A blank string should be returned
- self.assertEqual(result, '')
+ assert result == ''
def test_get_text_text(self):
"""
@@ -98,7 +98,7 @@
result = get_text(test_data)
# THEN: The text returned should be as expected
- self.assertEqual(result, 'Element text sub_text_tail text sub_text_tail tail sub_text text sub_tail tail')
+ assert result == 'Element text sub_text_tail text sub_text_tail tail sub_text text sub_tail tail'
def test_parse_chapter_number(self):
"""
@@ -109,7 +109,7 @@
result = parse_chapter_number('10', 0)
# THEN: The 10 should be returned as an Int
- self.assertEqual(result, 10)
+ assert result == 10
def test_parse_chapter_number_empty_attribute(self):
"""
@@ -120,7 +120,7 @@
result = parse_chapter_number('', 12)
# THEN: parse_chapter_number should increment the previous verse number
- self.assertEqual(result, 13)
+ assert result == 13
def test_parse_verse_number_valid_verse_no(self):
"""
@@ -133,7 +133,7 @@
result = importer.parse_verse_number('15', 0)
# THEN: parse_verse_number should return the verse number
- self.assertEqual(result, 15)
+ assert result == 15
def test_parse_verse_number_verse_range(self):
"""
@@ -146,7 +146,7 @@
result = importer.parse_verse_number('24-26', 0)
# THEN: parse_verse_number should return the first verse number in the range
- self.assertEqual(result, 24)
+ assert result == 24
def test_parse_verse_number_invalid_verse_no(self):
"""
@@ -159,7 +159,7 @@
result = importer.parse_verse_number('invalid', 41)
# THEN: parse_verse_number should increment the previous verse number
- self.assertEqual(result, 42)
+ assert result == 42
def test_parse_verse_number_empty_attribute(self):
"""
@@ -171,7 +171,7 @@
result = importer.parse_verse_number('', 14)
# THEN: parse_verse_number should increment the previous verse number
- self.assertEqual(result, 15)
+ assert result == 15
def test_parse_verse_number_invalid_type(self):
"""
@@ -187,7 +187,7 @@
# THEN: parse_verse_number should log the verse number it was called with increment the previous verse
# number
mocked_log_warning.assert_called_once_with('Illegal verse number: (1, 2, 3)')
- self.assertEqual(result, 13)
+ assert result == 13
def test_process_books_stop_import(self):
"""
@@ -201,7 +201,7 @@
importer.process_books(['Book'])
# THEN: find_and_create_book should not have been called
- self.assertFalse(self.mocked_find_and_create_book.called)
+ assert self.mocked_find_and_create_book.called is False
def test_process_books_completes(self):
"""
@@ -226,11 +226,10 @@
importer.process_books([book1, book2])
# THEN: find_and_create_book and process_books should be called with the details from the mocked books
- self.assertEqual(self.mocked_find_and_create_book.call_args_list,
- [call('Name1', 2, 10), call('Name2', 2, 10)])
- self.assertEqual(mocked_process_chapters.call_args_list,
- [call('db_book1', 'Chapter1'), call('db_book2', 'Chapter2')])
- self.assertEqual(importer.session.commit.call_count, 2)
+ assert self.mocked_find_and_create_book.call_args_list == [call('Name1', 2, 10), call('Name2', 2, 10)]
+ assert mocked_process_chapters.call_args_list == \
+ [call('db_book1', 'Chapter1'), call('db_book2', 'Chapter2')]
+ assert importer.session.commit.call_count == 2
def test_process_chapters_stop_import(self):
"""
@@ -245,7 +244,7 @@
importer.process_chapters('Book', ['Chapter1'])
# THEN: importer.parse_chapter_number not have been called
- self.assertFalse(importer.parse_chapter_number.called)
+ assert importer.parse_chapter_number.called is False
@patch('openlp.plugins.bibles.lib.importers.opensong.parse_chapter_number', **{'side_effect': [1, 2]})
def test_process_chapters_completes(self, mocked_parse_chapter_number):
@@ -273,12 +272,11 @@
importer.process_chapters(book, [chapter1, chapter2])
# THEN: parse_chapter_number, process_verses and increment_process_bar should have been called
- self.assertEqual(mocked_parse_chapter_number.call_args_list, [call('1', 0), call('2', 1)])
- self.assertEqual(
- importer.process_verses.call_args_list,
- [call(book, 1, ['Chapter1 Verses']), call(book, 2, ['Chapter2 Verses'])])
- self.assertEqual(importer.wizard.increment_progress_bar.call_args_list,
- [call('Importing Book 1...'), call('Importing Book 2...')])
+ assert mocked_parse_chapter_number.call_args_list == [call('1', 0), call('2', 1)]
+ assert importer.process_verses.call_args_list == \
+ [call(book, 1, ['Chapter1 Verses']), call(book, 2, ['Chapter2 Verses'])]
+ assert importer.wizard.increment_progress_bar.call_args_list == [call('Importing Book 1...'),
+ call('Importing Book 2...')]
def test_process_verses_stop_import(self):
"""
@@ -293,7 +291,7 @@
importer.process_verses('Book', 1, 'Verses')
# THEN: importer.parse_verse_number not have been called
- self.assertFalse(importer.parse_verse_number.called)
+ assert importer.parse_verse_number.called is False
def test_process_verses_completes(self):
"""
@@ -324,11 +322,10 @@
importer.process_verses(book, 1, [verse1, verse2])
# THEN: parse_chapter_number, process_verses and increment_process_bar should have been called
- self.assertEqual(mocked_parse_verse_number.call_args_list, [call('1', 0), call('2', 1)])
- self.assertEqual(mocked_get_text.call_args_list, [call(verse1), call(verse2)])
- self.assertEqual(
- importer.create_verse.call_args_list,
- [call(1, 1, 1, 'Verse1 Text'), call(1, 1, 2, 'Verse2 Text')])
+ assert mocked_parse_verse_number.call_args_list == [call('1', 0), call('2', 1)]
+ assert mocked_get_text.call_args_list == [call(verse1), call(verse2)]
+ assert importer.create_verse.call_args_list == \
+ [call(1, 1, 1, 'Verse1 Text'), call(1, 1, 2, 'Verse2 Text')]
def test_do_import_parse_xml_fails(self):
"""
@@ -345,8 +342,8 @@
result = importer.do_import()
# THEN: do_import should return False and get_language_id should have not been called
- self.assertFalse(result)
- self.assertFalse(mocked_language_id.called)
+ assert result is False
+ assert mocked_language_id.called is False
def test_do_import_no_language(self):
"""
@@ -364,8 +361,8 @@
result = importer.do_import()
# THEN: do_import should return False and process_books should have not been called
- self.assertFalse(result)
- self.assertFalse(mocked_process_books.called)
+ assert result is False
+ assert mocked_process_books.called is False
def test_do_import_completes(self):
"""
@@ -383,7 +380,7 @@
result = importer.do_import()
# THEN: do_import should return True
- self.assertTrue(result)
+ assert result is True
class TestOpenSongImportFileImports(TestCase, TestMixin):
@@ -421,6 +418,6 @@
importer.do_import()
# THEN: The create_verse() method should have been called with each verse in the file.
- self.assertTrue(importer.create_verse.called)
+ assert importer.create_verse.called is True
for verse_tag, verse_text in test_data['verses']:
importer.create_verse.assert_any_call(importer.create_book().id, 1, int(verse_tag), verse_text)
=== modified file 'tests/functional/openlp_plugins/bibles/test_osisimport.py'
--- tests/functional/openlp_plugins/bibles/test_osisimport.py 2017-11-06 22:41:36 +0000
+++ tests/functional/openlp_plugins/bibles/test_osisimport.py 2017-12-23 09:39:35 +0000
@@ -67,7 +67,7 @@
importer = OSISBible(mocked_manager, path='.', name='.', file_path=None)
# THEN: The importer should be an instance of BibleDB
- self.assertIsInstance(importer, BibleDB)
+ assert isinstance(importer, BibleDB)
def test_process_books_stop_import(self):
"""
@@ -82,7 +82,7 @@
importer.process_books(mocked_data)
# THEN: find_and_create_book should not have been called
- self.assertFalse(self.mocked_find_and_create_book.called)
+ assert self.mocked_find_and_create_book.called is False
def test_process_books_completes(self):
"""
@@ -106,11 +106,9 @@
importer.process_books(mocked_data)
# THEN: find_and_create_book and process_books should be called with the details from the mocked books
- self.assertEqual(self.mocked_find_and_create_book.call_args_list,
- [call('Name1', 2, 10), call('Name2', 2, 10)])
- self.assertEqual(mocked_process_chapters.call_args_list,
- [call('db_book1', book1), call('db_book2', book2)])
- self.assertEqual(importer.session.commit.call_count, 2)
+ assert self.mocked_find_and_create_book.call_args_list == [call('Name1', 2, 10), call('Name2', 2, 10)]
+ assert mocked_process_chapters.call_args_list == [call('db_book1', book1), call('db_book2', book2)]
+ assert importer.session.commit.call_count == 2
def test_process_chapters_verse_in_chapter_verse_text(self):
"""
@@ -185,8 +183,8 @@
importer.process_chapters(test_book, [test_chapter])
# THEN: neither set_current_chapter or process_verse should have been called
- self.assertFalse(mocked_set_current_chapter.called)
- self.assertFalse(mocked_process_verse.called)
+ assert mocked_set_current_chapter.called is False
+ assert mocked_process_verse.called is False
def test_process_chapters_milestones_chapter_sid(self):
"""
@@ -209,7 +207,7 @@
# THEN: set_current_chapter should have been called with the test data
mocked_set_current_chapter.assert_called_once_with(test_book.name, 2)
- self.assertFalse(mocked_process_verse.called)
+ assert mocked_process_verse.called is False
def test_process_chapters_milestones_verse_tag(self):
"""
@@ -233,7 +231,7 @@
importer.process_chapters(test_book, [test_verse])
# THEN: process_verse should have been called with the test data
- self.assertFalse(mocked_set_current_chapter.called)
+ assert mocked_set_current_chapter.called is False
mocked_process_verse.assert_called_once_with(test_book, 0, test_verse, use_milestones=True)
def test_process_verse_no_osis_id(self):
@@ -252,7 +250,7 @@
importer.process_verse(test_book, 2, test_verse)
# THEN: create_verse should not have been called
- self.assertFalse(self.mocked_create_verse.called)
+ assert self.mocked_create_verse.called is False
def test_process_verse_use_milestones_no_s_id(self):
"""
@@ -271,7 +269,7 @@
importer.process_verse(test_book, 2, test_verse)
# THEN: create_verse should not have been called
- self.assertFalse(self.mocked_create_verse.called)
+ assert self.mocked_create_verse.called is False
def test_process_verse_use_milestones_no_tail(self):
"""
@@ -289,7 +287,7 @@
importer.process_verse(test_book, 2, test_verse, use_milestones=True)
# THEN: create_verse should not have been called
- self.assertFalse(self.mocked_create_verse.called)
+ assert self.mocked_create_verse.called is False
def test_process_verse_use_milestones_success(self):
"""
@@ -327,7 +325,7 @@
importer.process_verse(test_book, 2, test_verse)
# THEN: create_verse should not have been called
- self.assertFalse(self.mocked_create_verse.called)
+ assert self.mocked_create_verse.called is False
def test_process_verse_success(self):
"""
@@ -363,8 +361,8 @@
result = importer.do_import()
# THEN: do_import should return False and get_language_id should have not been called
- self.assertFalse(result)
- self.assertFalse(mocked_language_id.called)
+ assert result is False
+ assert mocked_language_id.called is False
def test_do_import_no_language(self):
"""
@@ -382,8 +380,8 @@
result = importer.do_import()
# THEN: do_import should return False and process_books should have not been called
- self.assertFalse(result)
- self.assertFalse(mocked_process_books.called)
+ assert result is False
+ assert mocked_process_books.called is False
def test_do_import_completes(self):
"""
@@ -401,7 +399,7 @@
result = importer.do_import()
# THEN: do_import should return True
- self.assertTrue(result)
+ assert result is True
class TestOsisImportFileImports(TestCase):
@@ -442,7 +440,7 @@
importer.do_import()
# THEN: The create_verse() method should have been called with each verse in the file.
- self.assertTrue(importer.create_verse.called)
+ assert importer.create_verse.called is True
for verse_tag, verse_text in test_data['verses']:
importer.create_verse.assert_any_call(importer.create_book().id, 1, verse_tag, verse_text)
@@ -472,7 +470,7 @@
importer.do_import()
# THEN: The create_verse() method should have been called with each verse in the file.
- self.assertTrue(importer.create_verse.called)
+ assert importer.create_verse.called is True
for verse_tag, verse_text in test_data['verses']:
importer.create_verse.assert_any_call(importer.create_book().id, 1, verse_tag, verse_text)
@@ -502,7 +500,7 @@
importer.do_import()
# THEN: The create_verse() method should have been called with each verse in the file.
- self.assertTrue(importer.create_verse.called)
+ assert importer.create_verse.called
for verse_tag, verse_text in test_data['verses']:
importer.create_verse.assert_any_call(importer.create_book().id, 1, verse_tag, verse_text)
@@ -532,6 +530,6 @@
importer.do_import()
# THEN: The create_verse() method should have been called with each verse in the file.
- self.assertTrue(importer.create_verse.called)
+ assert importer.create_verse.called is True
for verse_tag, verse_text in test_data['verses']:
importer.create_verse.assert_any_call(importer.create_book().id, 1, verse_tag, verse_text)
=== modified file 'tests/functional/openlp_plugins/bibles/test_swordimport.py'
--- tests/functional/openlp_plugins/bibles/test_swordimport.py 2017-10-10 19:09:20 +0000
+++ tests/functional/openlp_plugins/bibles/test_swordimport.py 2017-12-23 09:39:35 +0000
@@ -67,7 +67,7 @@
importer = SwordBible(mocked_manager, path='.', name='.', file_path=None, sword_key='', sword_path='')
# THEN: The importer should be an instance of BibleDB
- self.assertIsInstance(importer, BibleDB)
+ assert isinstance(importer, BibleDB)
@patch('openlp.plugins.bibles.lib.importers.sword.SwordBible.application')
@patch('openlp.plugins.bibles.lib.importers.sword.modules')
@@ -106,6 +106,6 @@
importer.do_import()
# THEN: The create_verse() method should have been called with each verse in the file.
- self.assertTrue(importer.create_verse.called)
+ assert importer.create_verse.called is True
for verse_tag, verse_text in test_data['verses']:
importer.create_verse.assert_any_call(importer.create_book().id, 1, int(verse_tag), verse_text)
=== modified file 'tests/functional/openlp_plugins/bibles/test_versereferencelist.py'
--- tests/functional/openlp_plugins/bibles/test_versereferencelist.py 2016-12-31 11:01:36 +0000
+++ tests/functional/openlp_plugins/bibles/test_versereferencelist.py 2017-12-23 09:39:35 +0000
@@ -48,14 +48,12 @@
reference_list.add(book, chapter, verse, version, copyright_, permission)
# THEN: The entries should be in the first entry of the list
- self.assertEqual(reference_list.current_index, 0, 'The current index should be 0')
- self.assertEqual(reference_list.verse_list[0]['book'], book, 'The book in first entry should be %s' % book)
- self.assertEqual(reference_list.verse_list[0]['chapter'], chapter, 'The chapter in first entry should be %u' %
- chapter)
- self.assertEqual(reference_list.verse_list[0]['start'], verse, 'The start in first entry should be %u' % verse)
- self.assertEqual(reference_list.verse_list[0]['version'], version, 'The version in first entry should be %s' %
- version)
- self.assertEqual(reference_list.verse_list[0]['end'], verse, 'The end in first entry should be %u' % verse)
+ assert reference_list.current_index == 0, 'The current index should be 0'
+ assert reference_list.verse_list[0]['book'] == book, 'The book in first entry should be %s' % book
+ assert reference_list.verse_list[0]['chapter'] == chapter, 'The chapter in first entry should be %u' % chapter
+ assert reference_list.verse_list[0]['start'] == verse, 'The start in first entry should be %u' % verse
+ assert reference_list.verse_list[0]['version'] == version, 'The version in first entry should be %s' % version
+ assert reference_list.verse_list[0]['end'] == verse, 'The end in first entry should be %u' % verse
def test_add_next_verse(self):
"""
@@ -76,9 +74,8 @@
reference_list.add(book, chapter, next_verse, version, copyright_, permission)
# THEN: The current index should be 0 and the end pointer of the entry should be '2'
- self.assertEqual(reference_list.current_index, 0, 'The current index should be 0')
- self.assertEqual(reference_list.verse_list[0]['end'], next_verse,
- 'The end in first entry should be %u' % next_verse)
+ assert reference_list.current_index == 0, 'The current index should be 0'
+ assert reference_list.verse_list[0]['end'] == next_verse, 'The end in first entry should be %u' % next_verse
def test_add_another_verse(self):
"""
@@ -101,7 +98,7 @@
reference_list.add(another_book, another_chapter, another_verse, version, copyright_, permission)
# THEN: the current index should be 1
- self.assertEqual(reference_list.current_index, 1, 'The current index should be 1')
+ assert reference_list.current_index == 1, 'The current index should be 1'
def test_add_version(self):
"""
@@ -117,10 +114,10 @@
reference_list.add_version(version, copyright_, permission)
# THEN: the data will be appended to the list
- self.assertEqual(len(reference_list.version_list), 1, 'The version data should be appended')
- self.assertEqual(reference_list.version_list[0],
- {'version': version, 'copyright': copyright_, 'permission': permission},
- 'The version data should be appended')
+ assert len(reference_list.version_list) == 1, 'The version data should be appended'
+ assert reference_list.version_list[0] == \
+ {'version': version, 'copyright': copyright_, 'permission': permission}, \
+ 'The version data should be appended'
def test_add_existing_version(self):
"""
@@ -137,4 +134,4 @@
reference_list.add_version(version, copyright_, permission)
# THEN: the data will not be appended to the list
- self.assertEqual(len(reference_list.version_list), 1, 'The version data should not be appended')
+ assert len(reference_list.version_list) == 1, 'The version data should not be appended'
=== modified file 'tests/functional/openlp_plugins/bibles/test_zefaniaimport.py'
--- tests/functional/openlp_plugins/bibles/test_zefaniaimport.py 2017-10-10 19:09:20 +0000
+++ tests/functional/openlp_plugins/bibles/test_zefaniaimport.py 2017-12-23 09:39:35 +0000
@@ -59,7 +59,7 @@
importer = ZefaniaBible(mocked_manager, path='.', name='.', file_path=None)
# THEN: The importer should be an instance of BibleDB
- self.assertIsInstance(importer, BibleDB)
+ assert isinstance(importer, BibleDB)
def test_file_import(self):
"""
@@ -86,7 +86,7 @@
importer.do_import()
# THEN: The create_verse() method should have been called with each verse in the file.
- self.assertTrue(importer.create_verse.called)
+ assert importer.create_verse.called is True
for verse_tag, verse_text in test_data['verses']:
importer.create_verse.assert_any_call(importer.create_book().id, 1, verse_tag, verse_text)
importer.create_book.assert_any_call('Genesis', 1, 1)
@@ -116,7 +116,7 @@
importer.do_import()
# THEN: The create_verse() method should have been called with each verse in the file.
- self.assertTrue(importer.create_verse.called)
+ assert importer.create_verse.called is True
for verse_tag, verse_text in test_data['verses']:
importer.create_verse.assert_any_call(importer.create_book().id, 1, verse_tag, verse_text)
importer.create_book.assert_any_call('Exodus', 2, 1)
=== modified file 'tests/functional/openlp_plugins/custom/test_mediaitem.py'
--- tests/functional/openlp_plugins/custom/test_mediaitem.py 2017-10-07 07:05:07 +0000
+++ tests/functional/openlp_plugins/custom/test_mediaitem.py 2017-12-23 09:39:35 +0000
@@ -73,7 +73,7 @@
item = self.media_item.service_load(service_item)
# THEN: the processing should be ignored
- self.assertEqual(item, None, 'The Service item is inactive so processing should be bypassed')
+ assert item is None, 'The Service item is inactive so processing should be bypassed'
def test_service_load_basic_custom_false(self):
"""
@@ -95,8 +95,8 @@
self.media_item.service_load(service_item)
# THEN: the item should not be added to the database.
- self.assertEqual(self.media_item.create_from_service_item.call_count, 0,
- 'The item should not have been added to the database')
+ assert self.media_item.create_from_service_item.call_count == 0, \
+ 'The item should not have been added to the database'
def test_service_load_basic_custom_true(self):
"""
@@ -118,5 +118,5 @@
self.media_item.service_load(service_item)
# THEN: the item should not be added to the database.
- self.assertEqual(self.media_item.create_from_service_item.call_count, 1,
- 'The item should have been added to the database')
+ assert self.media_item.create_from_service_item.call_count == 1, \
+ 'The item should have been added to the database'
=== modified file 'tests/functional/openlp_plugins/images/test_imagetab.py'
--- tests/functional/openlp_plugins/images/test_imagetab.py 2017-10-07 07:05:07 +0000
+++ tests/functional/openlp_plugins/images/test_imagetab.py 2017-12-23 09:39:35 +0000
@@ -74,8 +74,8 @@
# WHEN: the save is invoked
self.form.save()
# THEN: the post process should not be requested
- self.assertEqual(0, self.form.settings_form.register_post_process.call_count,
- 'Image Post processing should not have been requested')
+ assert 0 == self.form.settings_form.register_post_process.call_count, \
+ 'Image Post processing should not have been requested'
def test_save_tab_change(self):
"""
@@ -86,7 +86,7 @@
# WHEN: the save is invoked
self.form.save()
# THEN: the post process should be requested
- self.assertEqual(1, self.form.settings_form.register_post_process.call_count,
- 'Image Post processing should have been requested')
+ assert 1 == self.form.settings_form.register_post_process.call_count, \
+ 'Image Post processing should have been requested'
# THEN: The color should be set
- self.assertEqual(self.form.background_color, '#999999', 'The updated color should have been saved')
+ assert self.form.background_color == '#999999', 'The updated color should have been saved'
=== modified file 'tests/functional/openlp_plugins/images/test_lib.py'
--- tests/functional/openlp_plugins/images/test_lib.py 2017-11-15 18:33:21 +0000
+++ tests/functional/openlp_plugins/images/test_lib.py 2017-12-23 09:39:35 +0000
@@ -98,8 +98,8 @@
self.media_item.save_new_images_list(image_list)
# THEN: The save_object() method should not have been called
- self.assertEquals(self.media_item.manager.save_object.call_count, 0,
- 'The save_object() method should not have been called')
+ assert self.media_item.manager.save_object.call_count == 0, \
+ 'The save_object() method should not have been called'
@patch('openlp.plugins.images.lib.mediaitem.ImageMediaItem.load_full_list')
def test_save_new_images_list_single_image_with_reload(self, mocked_load_full_list):
@@ -115,7 +115,7 @@
self.media_item.save_new_images_list(image_list, reload_list=True)
# THEN: load_full_list() should have been called
- self.assertEquals(mocked_load_full_list.call_count, 1, 'load_full_list() should have been called')
+ assert mocked_load_full_list.call_count == 1, 'load_full_list() should have been called'
# CLEANUP: Remove added attribute from ImageFilenames
delattr(ImageFilenames, 'file_path')
@@ -133,7 +133,7 @@
self.media_item.save_new_images_list(image_list, reload_list=False)
# THEN: load_full_list() should not have been called
- self.assertEquals(mocked_load_full_list.call_count, 0, 'load_full_list() should not have been called')
+ assert mocked_load_full_list.call_count == 0, 'load_full_list() should not have been called'
@patch('openlp.plugins.images.lib.mediaitem.ImageMediaItem.load_full_list')
def test_save_new_images_list_multiple_images(self, mocked_load_full_list):
@@ -148,8 +148,8 @@
self.media_item.save_new_images_list(image_list, reload_list=False)
# THEN: load_full_list() should not have been called
- self.assertEquals(self.media_item.manager.save_object.call_count, 3,
- 'load_full_list() should have been called three times')
+ assert self.media_item.manager.save_object.call_count == 3, \
+ 'load_full_list() should have been called three times'
@patch('openlp.plugins.images.lib.mediaitem.ImageMediaItem.load_full_list')
def test_save_new_images_list_other_objects_in_list(self, mocked_load_full_list):
@@ -164,8 +164,7 @@
self.media_item.save_new_images_list(image_list, reload_list=False)
# THEN: load_full_list() should not have been called
- self.assertEquals(self.media_item.manager.save_object.call_count, 2,
- 'load_full_list() should have been called only once')
+ assert self.media_item.manager.save_object.call_count == 2, 'load_full_list() should have been called only once'
def test_on_reset_click(self):
"""
@@ -201,9 +200,9 @@
self.media_item.recursively_delete_group(test_group)
# THEN: delete_file() should have been called 12 times and manager.delete_object() 7 times.
- self.assertEquals(mocked_delete_file.call_count, 12, 'delete_file() should have been called 12 times')
- self.assertEquals(self.media_item.manager.delete_object.call_count, 7,
- 'manager.delete_object() should be called exactly 7 times')
+ assert mocked_delete_file.call_count == 12, 'delete_file() should have been called 12 times'
+ assert self.media_item.manager.delete_object.call_count == 7, \
+ 'manager.delete_object() should be called exactly 7 times'
# CLEANUP: Remove added attribute from Image Filenames and ImageGroups
delattr(ImageFilenames, 'group_id')
@@ -258,7 +257,7 @@
self.media_item.on_delete_click()
# THEN: delete_file should have been called twice
- self.assertEquals(mocked_delete_file.call_count, 2, 'delete_file() should have been called twice')
+ assert mocked_delete_file.call_count == 2, 'delete_file() should have been called twice'
def test_create_item_from_id(self):
"""
@@ -276,9 +275,9 @@
item = self.media_item.create_item_from_id('1')
# THEN: A QTreeWidgetItem should be created with the above model object as it's data
- self.assertIsInstance(item, QtWidgets.QTreeWidgetItem)
- self.assertEqual('test_file_1.jpg', item.text(0))
+ assert isinstance(item, QtWidgets.QTreeWidgetItem)
+ assert 'test_file_1.jpg' == item.text(0)
item_data = item.data(0, QtCore.Qt.UserRole)
- self.assertIsInstance(item_data, ImageFilenames)
- self.assertEqual(1, item_data.id)
- self.assertEqual(Path('/', 'tmp', 'test_file_1.jpg'), item_data.file_path)
+ assert isinstance(item_data, ImageFilenames)
+ assert 1 == item_data.id
+ assert Path('/', 'tmp', 'test_file_1.jpg') == item_data.file_path
=== modified file 'tests/functional/openlp_plugins/images/test_upgrade.py'
--- tests/functional/openlp_plugins/images/test_upgrade.py 2017-10-10 02:29:56 +0000
+++ tests/functional/openlp_plugins/images/test_upgrade.py 2017-12-23 09:39:35 +0000
@@ -80,6 +80,6 @@
2: Path('/', 'test', 'dir', 'image2.jpg'),
3: Path('/', 'test', 'dir', 'subdir', 'image3.jpg')}
- self.assertEqual(len(upgraded_results), 3)
+ assert len(upgraded_results) == 3
for result in upgraded_results:
- self.assertEqual(expected_result_data[result.id], result.file_path)
+ assert expected_result_data[result.id] == result.file_path
=== modified file 'tests/functional/openlp_plugins/media/test_mediaitem.py'
--- tests/functional/openlp_plugins/media/test_mediaitem.py 2017-10-10 07:08:44 +0000
+++ tests/functional/openlp_plugins/media/test_mediaitem.py 2017-12-23 09:39:35 +0000
@@ -71,7 +71,7 @@
# WHEN: Retrieving the test file
result = self.media_item.search('test.mp4', False)
# THEN: a file should be found
- self.assertEqual(result, [['test.mp4', 'test.mp4']], 'The result file contain the file name')
+ assert result == [['test.mp4', 'test.mp4']], 'The result file contain the file name'
def test_search_not_found(self):
"""
@@ -82,4 +82,4 @@
# WHEN: Retrieving the test file
result = self.media_item.search('test.mpx', False)
# THEN: a file should be found
- self.assertEqual(result, [], 'The result file should be empty')
+ assert result == [], 'The result file should be empty'
=== modified file 'tests/functional/openlp_plugins/media/test_mediaplugin.py'
--- tests/functional/openlp_plugins/media/test_mediaplugin.py 2017-10-10 07:08:44 +0000
+++ tests/functional/openlp_plugins/media/test_mediaplugin.py 2017-12-23 09:39:35 +0000
@@ -56,9 +56,9 @@
# GIVEN: The MediaPlugin
# WHEN: Retrieving the about text
# THEN: about() should return a string object
- self.assertIsInstance(MediaPlugin.about(), str)
+ assert isinstance(MediaPlugin.about(), str)
# THEN: about() should return a non-empty string
- self.assertNotEquals(len(MediaPlugin.about()), 0)
+ assert len(MediaPlugin.about()) is not 0
@patch('openlp.plugins.media.mediaplugin.check_binary_exists')
def test_process_check_binary_pass(self, mocked_checked_binary_exists):
@@ -71,7 +71,7 @@
result = process_check_binary('MediaInfo')
# THEN: The the result should be True
- self.assertTrue(result, 'Mediainfo should have been found')
+ assert result is True, 'Mediainfo should have been found'
@patch('openlp.plugins.media.mediaplugin.check_binary_exists')
def test_process_check_binary_fail(self, mocked_checked_binary_exists):
@@ -84,4 +84,4 @@
result = process_check_binary("MediaInfo1")
# THEN: The the result should be True
- self.assertFalse(result, "Mediainfo should not have been found")
+ assert result is False, "Mediainfo should not have been found"
=== modified file 'tests/functional/openlp_plugins/presentations/test_impresscontroller.py'
--- tests/functional/openlp_plugins/presentations/test_impresscontroller.py 2017-12-17 15:28:21 +0000
+++ tests/functional/openlp_plugins/presentations/test_impresscontroller.py 2017-12-23 09:39:35 +0000
@@ -69,8 +69,7 @@
controller = ImpressController(plugin=self.mock_plugin)
# THEN: The name of the presentation controller should be correct
- self.assertEqual('Impress', controller.name,
- 'The name of the presentation controller should be correct')
+ assert 'Impress' == controller.name, 'The name of the presentation controller should be correct'
@patch('openlp.plugins.presentations.lib.impresscontroller.log')
def test_check_available(self, mocked_log):
@@ -179,22 +178,21 @@
result = self.doc._ImpressDocument__get_text_from_page(0, TextType.Notes)
# THEN: the result should be an empty string
- self.assertEqual(result, '', 'Result should be an empty string')
+ assert result == '', 'Result should be an empty string'
# WHEN: regardless of the type of text, index 0x00 is out of bounds
result = self.doc._ImpressDocument__get_text_from_page(0, TextType.Title)
# THEN: result should be an empty string
- self.assertEqual(result, '', 'Result should be an empty string')
+ assert result == '', 'Result should be an empty string'
# WHEN: when called with 2, it should also be out of bounds
result = self.doc._ImpressDocument__get_text_from_page(2, TextType.SlideText)
# THEN: result should be an empty string ... and, getByIndex should
# have never been called
- self.assertEqual(result, '', 'Result should be an empty string')
- self.assertEqual(self.doc.document.getDrawPages().getByIndex.call_count, 0,
- 'There should be no call to getByIndex')
+ assert result == '', 'Result should be an empty string'
+ assert self.doc.document.getDrawPages().getByIndex.call_count == 0, 'There should be no call to getByIndex'
def test_get_text_from_page_wrong_type(self):
"""
@@ -208,9 +206,8 @@
result = self.doc._ImpressDocument__get_text_from_page(1, 3)
# THEN: result should be an empty string
- self.assertEqual(result, '', 'Result should be and empty string')
- self.assertEqual(self.doc.document.getDrawPages().getByIndex.call_count, 0,
- 'There should be no call to getByIndex')
+ assert result == '', 'Result should be and empty string'
+ assert self.doc.document.getDrawPages().getByIndex.call_count == 0, 'There should be no call to getByIndex'
def test_get_text_from_page_valid_params(self):
"""
@@ -224,19 +221,19 @@
result = self.doc._ImpressDocument__get_text_from_page(1, TextType.Notes)
# THEN: result should be 'Note\nNote\n'
- self.assertEqual(result, 'Note\nNote\n', 'Result should be \'Note\\n\' times the count of notes in the page')
+ assert result == 'Note\nNote\n', 'Result should be \'Note\\n\' times the count of notes in the page'
# WHEN: get the Title
result = self.doc._ImpressDocument__get_text_from_page(1, TextType.Title)
# THEN: result should be 'Title\n'
- self.assertEqual(result, 'Title\n', 'Result should be exactly \'Title\\n\'')
+ assert result == 'Title\n', 'Result should be exactly \'Title\\n\''
# WHEN: get all text
result = self.doc._ImpressDocument__get_text_from_page(1, TextType.SlideText)
# THEN: result should be 'Title\nString\nString\n'
- self.assertEqual(result, 'Title\nString\nString\n', 'Result should be exactly \'Title\\nString\\nString\\n\'')
+ assert result == 'Title\nString\nString\n', 'Result should be exactly \'Title\\nString\\nString\\n\''
def _mock_a_LibreOffice_document(self, page_count, note_count, text_count):
"""
=== modified file 'tests/functional/openlp_plugins/presentations/test_mediaitem.py'
--- tests/functional/openlp_plugins/presentations/test_mediaitem.py 2017-11-13 20:07:20 +0000
+++ tests/functional/openlp_plugins/presentations/test_mediaitem.py 2017-12-23 09:39:35 +0000
@@ -81,11 +81,11 @@
self.media_item.build_file_mask_string()
# THEN: The file mask should be generated correctly
- self.assertIn('*.odp', self.media_item.on_new_file_masks, 'The file mask should contain the odp extension')
- self.assertIn('*.ppt', self.media_item.on_new_file_masks, 'The file mask should contain the ppt extension')
- self.assertIn('*.pdf', self.media_item.on_new_file_masks, 'The file mask should contain the pdf extension')
- self.assertIn('*.xps', self.media_item.on_new_file_masks, 'The file mask should contain the xps extension')
- self.assertIn('*.oxps', self.media_item.on_new_file_masks, 'The file mask should contain the oxps extension')
+ assert '*.odp' in self.media_item.on_new_file_masks, 'The file mask should contain the odp extension'
+ assert '*.ppt' in self.media_item.on_new_file_masks, 'The file mask should contain the ppt extension'
+ assert '*.pdf' in self.media_item.on_new_file_masks, 'The file mask should contain the pdf extension'
+ assert '*.xps' in self.media_item.on_new_file_masks, 'The file mask should contain the xps extension'
+ assert '*.oxps' in self.media_item.on_new_file_masks, 'The file mask should contain the oxps extension'
def test_clean_up_thumbnails(self):
"""
=== modified file 'tests/functional/openlp_plugins/presentations/test_messagelistener.py'
--- tests/functional/openlp_plugins/presentations/test_messagelistener.py 2017-10-07 07:05:07 +0000
+++ tests/functional/openlp_plugins/presentations/test_messagelistener.py 2017-12-23 09:39:35 +0000
@@ -73,7 +73,7 @@
ml.startup([mock_item, False, False, False])
# THEN: The controllers will be setup.
- self.assertTrue(len(controllers), 'We have loaded a controller')
+ assert len(controllers) > 0, 'We have loaded a controller'
@patch('openlp.plugins.presentations.lib.mediaitem.MessageListener._setup')
def test_start_presentation_with_no_player(self, media_mock):
@@ -105,7 +105,7 @@
ml.startup([mock_item, False, False, False])
# THEN: The controllers will be setup.
- self.assertTrue(len(controllers), 'We have loaded a controller')
+ assert len(controllers) > 0, 'We have loaded a controller'
@patch('openlp.plugins.presentations.lib.mediaitem.MessageListener._setup')
def test_start_pdf_presentation(self, media_mock):
@@ -125,7 +125,7 @@
ml.startup([mock_item, False, False, False])
# THEN: The handler should be set to None
- self.assertIsNone(ml.handler, 'The handler should be None')
+ assert ml.handler is None, 'The handler should be None'
class TestController(TestCase, TestMixin):
@@ -148,4 +148,4 @@
controller.add_handler(mocked_doc_controller, MagicMock(), True, 0)
# THEN: slidenumber should be 0
- self.assertEqual(controller.doc.slidenumber, 0, 'doc.slidenumber should be 0')
+ assert controller.doc.slidenumber == 0, 'doc.slidenumber should be 0'
=== modified file 'tests/functional/openlp_plugins/presentations/test_pdfcontroller.py'
--- tests/functional/openlp_plugins/presentations/test_pdfcontroller.py 2017-11-18 11:23:15 +0000
+++ tests/functional/openlp_plugins/presentations/test_pdfcontroller.py 2017-12-23 09:39:35 +0000
@@ -92,7 +92,7 @@
controller = PdfController(plugin=self.mock_plugin)
# THEN: The name of the presentation controller should be correct
- self.assertEqual('Pdf', controller.name, 'The name of the presentation controller should be correct')
+ assert'Pdf' == controller.name, 'The name of the presentation controller should be correct'
def test_load_pdf(self):
"""
@@ -111,8 +111,8 @@
loaded = document.load_presentation()
# THEN: The load should succeed and we should be able to get a pagecount
- self.assertTrue(loaded, 'The loading of the PDF should succeed.')
- self.assertEqual(3, document.get_slide_count(), 'The pagecount of the PDF should be 3.')
+ assert loaded is True, 'The loading of the PDF should succeed.'
+ assert 3 == document.get_slide_count(), 'The pagecount of the PDF should be 3.'
def test_load_pdf_pictures(self):
"""
@@ -131,15 +131,15 @@
loaded = document.load_presentation()
# THEN: The load should succeed and pictures should be created and have been scales to fit the screen
- self.assertTrue(loaded, 'The loading of the PDF should succeed.')
+ assert loaded is True, 'The loading of the PDF should succeed.'
image = QtGui.QImage(os.path.join(str(self.temp_folder_path), 'pdf_test1.pdf', 'mainslide001.png'))
# Based on the converter used the resolution will differ a bit
if controller.gsbin:
- self.assertEqual(760, image.height(), 'The height should be 760')
- self.assertEqual(537, image.width(), 'The width should be 537')
+ assert 760 == image.height(), 'The height should be 760'
+ assert 537 == image.width(), 'The width should be 537'
else:
- self.assertEqual(768, image.height(), 'The height should be 768')
- self.assertEqual(543, image.width(), 'The width should be 543')
+ assert 768 == image.height(), 'The height should be 768'
+ assert 543 == image.width(), 'The width should be 543'
@patch('openlp.plugins.presentations.lib.pdfcontroller.check_binary_exists')
def test_process_check_binary_mudraw(self, mocked_check_binary_exists):
@@ -157,7 +157,7 @@
ret = PdfController.process_check_binary('test')
# THEN: mudraw should be detected
- self.assertEqual('mudraw', ret, 'mudraw should have been detected')
+ assert 'mudraw' == ret, 'mudraw should have been detected'
@patch('openlp.plugins.presentations.lib.pdfcontroller.check_binary_exists')
def test_process_check_binary_new_motool(self, mocked_check_binary_exists):
@@ -177,7 +177,7 @@
ret = PdfController.process_check_binary('test')
# THEN: mutool should be detected
- self.assertEqual('mutool', ret, 'mutool should have been detected')
+ assert 'mutool' == ret, 'mutool should have been detected'
@patch('openlp.plugins.presentations.lib.pdfcontroller.check_binary_exists')
def test_process_check_binary_old_motool(self, mocked_check_binary_exists):
@@ -194,7 +194,7 @@
ret = PdfController.process_check_binary('test')
# THEN: mutool should be detected
- self.assertIsNone(ret, 'old mutool should not be accepted!')
+ assert ret is None, 'old mutool should not be accepted!'
@patch('openlp.plugins.presentations.lib.pdfcontroller.check_binary_exists')
def test_process_check_binary_gs(self, mocked_check_binary_exists):
@@ -210,4 +210,4 @@
ret = PdfController.process_check_binary('test')
# THEN: mutool should be detected
- self.assertEqual('gs', ret, 'mutool should have been detected')
+ assert 'gs' == ret, 'mutool should have been detected'
=== modified file 'tests/functional/openlp_plugins/presentations/test_powerpointcontroller.py'
--- tests/functional/openlp_plugins/presentations/test_powerpointcontroller.py 2017-10-07 07:05:07 +0000
+++ tests/functional/openlp_plugins/presentations/test_powerpointcontroller.py 2017-12-23 09:39:35 +0000
@@ -77,8 +77,7 @@
controller = PowerpointController(plugin=self.mock_plugin)
# THEN: The name of the presentation controller should be correct
- self.assertEqual('Powerpoint', controller.name,
- 'The name of the presentation controller should be correct')
+ assert 'Powerpoint' == controller.name, 'The name of the presentation controller should be correct'
class TestPowerpointDocument(TestCase, TestMixin):
@@ -157,7 +156,7 @@
result = doc.is_loaded()
# THEN: result should be true
- self.assertEqual(result, True, 'The result should be True')
+ assert result is True, 'The result should be True'
else:
self.skipTest('Powerpoint not available, skipping test.')
@@ -217,7 +216,7 @@
result = _get_text_from_shapes(shapes)
# THEN: it should return the text
- self.assertEqual(result, 'slideText\nslideText\n', 'result should match \'slideText\nslideText\n\'')
+ assert result == 'slideText\nslideText\n', 'result should match \'slideText\nslideText\n\''
def test_get_text_from_shapes_with_no_shapes(self):
"""
@@ -230,7 +229,7 @@
result = _get_text_from_shapes(shapes)
# THEN: it should not fail but return empty string
- self.assertEqual(result, '', 'result should be empty')
+ assert result == '', 'result should be empty'
def test_goto_slide(self):
"""
@@ -250,7 +249,7 @@
doc.goto_slide(1)
# THEN: next_step() should be call to try to advance to the next effect.
- self.assertTrue(doc.next_step.called, 'next_step() should have been called!')
+ assert doc.next_step.called, 'next_step() should have been called!' is True
def test_blank_screen(self):
"""
@@ -268,9 +267,9 @@
doc.blank_screen()
# THEN: The view state, doc.blank_slide and doc.blank_click should have new values
- self.assertEquals(doc.presentation.SlideShowWindow.View.State, 3, 'The View State should be 3')
- self.assertEquals(doc.blank_slide, 2, 'doc.blank_slide should be 2 because of the PowerPoint version')
- self.assertEquals(doc.blank_click, 3, 'doc.blank_click should be 3 because of the PowerPoint version')
+ assert doc.presentation.SlideShowWindow.View.State == 3, 'The View State should be 3'
+ assert doc.blank_slide == 2, 'doc.blank_slide should be 2 because of the PowerPoint version'
+ assert doc.blank_click == 3, 'doc.blank_click should be 3 because of the PowerPoint version'
def test_unblank_screen(self):
"""
@@ -295,10 +294,10 @@
doc.unblank_screen()
# THEN: The view state have new value, and several function should have been called
- self.assertEquals(doc.presentation.SlideShowWindow.View.State, 1, 'The View State should be 1')
- self.assertEquals(doc.presentation.SlideShowWindow.Activate.called, True,
- 'SlideShowWindow.Activate should have been called')
- self.assertEquals(doc.presentation.SlideShowWindow.View.GotoSlide.called, True,
- 'View.GotoSlide should have been called because of the PowerPoint version')
- self.assertEquals(doc.presentation.SlideShowWindow.View.GotoClick.called, True,
- 'View.GotoClick should have been called because of the PowerPoint version')
+ assert doc.presentation.SlideShowWindow.View.State == 1, 'The View State should be 1'
+ assert doc.presentation.SlideShowWindow.Activate.called is True, \
+ 'SlideShowWindow.Activate should have been called'
+ assert doc.presentation.SlideShowWindow.View.GotoSlide.called is True, \
+ 'View.GotoSlide should have been called because of the PowerPoint version'
+ assert doc.presentation.SlideShowWindow.View.GotoClick.called is True, \
+ 'View.GotoClick should have been called because of the PowerPoint version'
=== modified file 'tests/functional/openlp_plugins/presentations/test_pptviewcontroller.py'
--- tests/functional/openlp_plugins/presentations/test_pptviewcontroller.py 2017-10-07 07:05:07 +0000
+++ tests/functional/openlp_plugins/presentations/test_pptviewcontroller.py 2017-12-23 09:39:35 +0000
@@ -67,8 +67,7 @@
controller = PptviewController(plugin=self.mock_plugin)
# THEN: The name of the presentation controller should be correct
- self.assertEqual('Powerpoint Viewer', controller.name,
- 'The name of the presentation controller should be correct')
+ assert'Powerpoint Viewer' == controller.name, 'The name of the presentation controller should be correct'
def test_check_available(self):
"""
@@ -86,9 +85,9 @@
# THEN: On windows it should return True, on other platforms False
if is_win():
- self.assertTrue(available, 'check_available should return True on windows.')
+ assert available is True, 'check_available should return True on windows.'
else:
- self.assertFalse(available, 'check_available should return False when not on windows.')
+ assert available is False, 'check_available should return False when not on windows.'
class TestPptviewDocument(TestCase):
@@ -165,7 +164,7 @@
result = instance.load_presentation()
# THEN: The temp folder should be created and PptviewDocument.load_presentation should return False
- self.assertFalse(result)
+ assert result is False
def test_create_titles_and_notes(self):
"""
@@ -205,7 +204,7 @@
# THEN: File existens should have been checked, and not have been opened.
doc.save_titles_and_notes.assert_called_once_with(None, None)
mocked_path_exists.assert_called_with()
- self.assertEqual(mocked_open.call_count, 0, 'There should be no calls to open a file.')
+ assert mocked_open.call_count == 0, 'There should be no calls to open a file.'
def test_create_titles_and_notes_invalid_file(self):
"""
@@ -225,4 +224,4 @@
# THEN:
doc.save_titles_and_notes.assert_called_once_with(None, None)
- self.assertEqual(mocked_is_zf.call_count, 1, 'is_zipfile should have been called once')
+ assert mocked_is_zf.call_count == 1, 'is_zipfile should have been called once'
=== modified file 'tests/functional/openlp_plugins/presentations/test_presentationcontroller.py'
--- tests/functional/openlp_plugins/presentations/test_presentationcontroller.py 2017-11-03 20:55:41 +0000
+++ tests/functional/openlp_plugins/presentations/test_presentationcontroller.py 2017-12-23 09:39:35 +0000
@@ -58,8 +58,8 @@
# WHEN: The PresentationController is created
# THEN: The name of the presentation controller should be correct
- self.assertEqual('PresentationController', self.presentation.name,
- 'The name of the presentation controller should be correct')
+ assert 'PresentationController' == self.presentation.name, \
+ 'The name of the presentation controller should be correct'
def test_save_titles_and_notes(self):
"""
@@ -76,7 +76,7 @@
self.document.save_titles_and_notes(titles, notes)
# THEN: the last call to open should have been for slideNotes2.txt
- self.assertEqual(mocked_write_text.call_count, 3, 'There should be exactly three files written')
+ assert mocked_write_text.call_count == 3, 'There should be exactly three files written'
mocked_write_text.assert_has_calls([call('uno\ndos'), call('one'), call('two')])
def test_save_titles_and_notes_with_None(self):
@@ -93,7 +93,7 @@
self.document.save_titles_and_notes(titles, notes)
# THEN: No file should have been created
- self.assertEqual(mocked_open.call_count, 0, 'No file should be created')
+ assert mocked_open.call_count == 0, 'No file should be created'
def test_get_titles_and_notes(self):
"""
@@ -112,11 +112,11 @@
result_titles, result_notes = self.document.get_titles_and_notes()
# THEN: it should return two items for the titles and two empty strings for the notes
- self.assertIs(type(result_titles), list, 'result_titles should be of type list')
- self.assertEqual(len(result_titles), 2, 'There should be two items in the titles')
- self.assertIs(type(result_notes), list, 'result_notes should be of type list')
- self.assertEqual(len(result_notes), 2, 'There should be two items in the notes')
- self.assertEqual(mocked_read_text.call_count, 3, 'Three files should be read')
+ assert type(result_titles) is list, 'result_titles should be of type list'
+ assert len(result_titles) == 2, 'There should be two items in the titles'
+ assert type(result_notes) is list, 'result_notes should be of type list'
+ assert len(result_notes) == 2, 'There should be two items in the notes'
+ assert mocked_read_text.call_count == 3, 'Three files should be read'
def test_get_titles_and_notes_with_file_not_found(self):
"""
@@ -132,10 +132,10 @@
result_titles, result_notes = self.document.get_titles_and_notes()
# THEN: it should return two empty lists
- self.assertIsInstance(result_titles, list, 'result_titles should be of type list')
- self.assertEqual(len(result_titles), 0, 'there be no titles')
- self.assertIsInstance(result_notes, list, 'result_notes should be a list')
- self.assertEqual(len(result_notes), 0, 'but the list should be empty')
+ assert isinstance(result_titles, list), 'result_titles should be of type list'
+ assert len(result_titles) == 0, 'there be no titles'
+ assert isinstance(result_notes, list), 'result_notes should be a list'
+ assert len(result_notes) == 0, 'but the list should be empty'
def test_get_titles_and_notes_with_file_error(self):
"""
@@ -151,7 +151,7 @@
result_titles, result_notes = self.document.get_titles_and_notes()
# THEN: it should return two empty lists
- self.assertIs(type(result_titles), list, 'result_titles should be a list')
+ assert type(result_titles) is list, 'result_titles should be a list'
class TestPresentationDocument(TestCase):
@@ -226,4 +226,4 @@
result = instance.load_presentation()
# THEN: load_presentation should return false
- self.assertFalse(result, "PresentationDocument.load_presentation should return false.")
+ assert result is False, "PresentationDocument.load_presentation should return false."
=== modified file 'tests/functional/openlp_plugins/songs/test_db.py'
--- tests/functional/openlp_plugins/songs/test_db.py 2017-04-25 19:52:20 +0000
+++ tests/functional/openlp_plugins/songs/test_db.py 2017-12-23 09:39:35 +0000
@@ -66,10 +66,10 @@
song.add_author(author)
# THEN: The author should have been added with author_type=None
- self.assertEqual(1, len(song.authors_songs))
- self.assertEqual("Max", song.authors_songs[0].author.first_name)
- self.assertEqual("Mustermann", song.authors_songs[0].author.last_name)
- self.assertIsNone(song.authors_songs[0].author_type)
+ assert 1 == len(song.authors_songs)
+ assert "Max" == song.authors_songs[0].author.first_name
+ assert "Mustermann" == song.authors_songs[0].author.last_name
+ assert song.authors_songs[0].author_type is None
def test_add_author_with_type(self):
"""
@@ -86,10 +86,10 @@
song.add_author(author, AuthorType.Words)
# THEN: The author should have been added with author_type=None
- self.assertEqual(1, len(song.authors_songs))
- self.assertEqual("Max", song.authors_songs[0].author.first_name)
- self.assertEqual("Mustermann", song.authors_songs[0].author.last_name)
- self.assertEqual(AuthorType.Words, song.authors_songs[0].author_type)
+ assert 1 == len(song.authors_songs)
+ assert "Max" == song.authors_songs[0].author.first_name
+ assert "Mustermann" == song.authors_songs[0].author.last_name
+ assert AuthorType.Words == song.authors_songs[0].author_type
def test_remove_author(self):
"""
@@ -105,7 +105,7 @@
song.remove_author(author)
# THEN: It should have been removed
- self.assertEqual(0, len(song.authors_songs))
+ assert 0 == len(song.authors_songs)
def test_remove_author_with_type(self):
"""
@@ -122,8 +122,8 @@
song.remove_author(author, AuthorType.Translation)
# THEN: It should have been removed and the other author should still be there
- self.assertEqual(1, len(song.authors_songs))
- self.assertEqual(None, song.authors_songs[0].author_type)
+ assert 1 == len(song.authors_songs)
+ assert song.authors_songs[0].author_type is None
def test_get_author_type_from_translated_text(self):
"""
@@ -136,7 +136,7 @@
author_type = AuthorType.from_translated_text(author_type_name)
# THEN: The type should be correct
- self.assertEqual(author_type, AuthorType.Words)
+ assert author_type == AuthorType.Words
def test_author_get_display_name(self):
"""
@@ -150,7 +150,7 @@
display_name = author.get_display_name()
# THEN: It should return only the name
- self.assertEqual("John Doe", display_name)
+ assert "John Doe" == display_name
def test_author_get_display_name_with_type_words(self):
"""
@@ -164,7 +164,7 @@
display_name = author.get_display_name(AuthorType.Words)
# THEN: It should return the name with the type in brackets
- self.assertEqual("John Doe (Words)", display_name)
+ assert "John Doe (Words)" == display_name
def test_author_get_display_name_with_type_translation(self):
"""
@@ -178,7 +178,7 @@
display_name = author.get_display_name(AuthorType.Translation)
# THEN: It should return the name with the type in brackets
- self.assertEqual("John Doe (Translation)", display_name)
+ assert "John Doe (Translation)" == display_name
def test_add_songbooks(self):
"""
@@ -195,7 +195,7 @@
song.add_songbook_entry(songbook, "550A")
# THEN: The song should have two songbook entries
- self.assertEqual(len(song.songbook_entries), 2, 'There should be two Songbook entries.')
+ assert len(song.songbook_entries) == 2, 'There should be two Songbook entries.'
def test_upgrade_old_song_db(self):
"""
@@ -211,8 +211,7 @@
updated_to_version, latest_version = upgrade_db(db_url, upgrade)
# THEN: the song db should have been upgraded to the latest version
- self.assertEqual(updated_to_version, latest_version,
- 'The song DB should have been upgrade to the latest version')
+ assert updated_to_version == latest_version, 'The song DB should have been upgrade to the latest version'
def test_upgrade_invalid_song_db(self):
"""
@@ -228,5 +227,4 @@
updated_to_version, latest_version = upgrade_db(db_url, upgrade)
# THEN: the song db should have been upgraded to the latest version without errors
- self.assertEqual(updated_to_version, latest_version,
- 'The song DB should have been upgrade to the latest version')
+ assert updated_to_version == latest_version, 'The song DB should have been upgrade to the latest version'
=== modified file 'tests/functional/openlp_plugins/songs/test_editsongform.py'
--- tests/functional/openlp_plugins/songs/test_editsongform.py 2017-10-07 07:05:07 +0000
+++ tests/functional/openlp_plugins/songs/test_editsongform.py 2017-12-23 09:39:35 +0000
@@ -64,7 +64,7 @@
valid = self.edit_song_form._validate_tags(tags)
# THEN they should be valid
- self.assertTrue(valid, "The tags list should be valid")
+ assert valid is True, "The tags list should be valid"
def test_validate_nonmatching_tags(self):
# Given a set of tags
@@ -74,7 +74,7 @@
valid = self.edit_song_form._validate_tags(tags)
# THEN they should be valid
- self.assertTrue(valid, "The tags list should be valid")
+ assert valid is True, "The tags list should be valid"
@patch('openlp.plugins.songs.forms.editsongform.set_case_insensitive_completer')
def test_load_objects(self, mocked_set_case_insensitive_completer):
=== modified file 'tests/functional/openlp_plugins/songs/test_editverseform.py'
--- tests/functional/openlp_plugins/songs/test_editverseform.py 2017-10-10 02:29:56 +0000
+++ tests/functional/openlp_plugins/songs/test_editverseform.py 2017-12-23 09:39:35 +0000
@@ -71,7 +71,7 @@
self.edit_verse_form.update_suggested_verse_number()
# THEN the verse number must not be changed
- self.assertEqual(3, self.edit_verse_form.verse_number_box.value(), 'The verse number should be 3')
+ assert 3 == self.edit_verse_form.verse_number_box.value(), 'The verse number should be 3'
def test_on_divide_split_button_clicked(self):
"""
@@ -84,8 +84,8 @@
# WHEN the method is called
self.edit_verse_form.on_forced_split_button_clicked()
# THEN the verse number must not be changed
- self.assertEqual('[--}{--]\nText\n', self.edit_verse_form.verse_text_edit.toPlainText(),
- 'The verse number should be [--}{--]\nText\n')
+ assert '[--}{--]\nText\n' == self.edit_verse_form.verse_text_edit.toPlainText(), \
+ 'The verse number should be [--}{--]\nText\n'
def test_on_split_button_clicked(self):
"""
@@ -98,5 +98,5 @@
# WHEN the method is called
self.edit_verse_form.on_overflow_split_button_clicked()
# THEN the verse number must not be changed
- self.assertEqual('[---]\nText\n', self.edit_verse_form.verse_text_edit.toPlainText(),
- 'The verse number should be [---]\nText\n')
+ assert '[---]\nText\n' == self.edit_verse_form.verse_text_edit.toPlainText(), \
+ 'The verse number should be [---]\nText\n'
=== modified file 'tests/functional/openlp_plugins/songs/test_ewimport.py'
--- tests/functional/openlp_plugins/songs/test_ewimport.py 2017-12-22 10:45:39 +0000
+++ tests/functional/openlp_plugins/songs/test_ewimport.py 2017-12-23 09:39:35 +0000
@@ -165,11 +165,10 @@
field_desc_entry = FieldDescEntry(name, field_type, size)
# THEN:
- self.assertIsNotNone(field_desc_entry, 'Import should not be none')
- self.assertEqual(field_desc_entry.name, name, 'FieldDescEntry.name should be the same as the name argument')
- self.assertEqual(field_desc_entry.field_type, field_type,
- 'FieldDescEntry.type should be the same as the type argument')
- self.assertEqual(field_desc_entry.size, size, 'FieldDescEntry.size should be the same as the size argument')
+ assert field_desc_entry is not None, 'Import should not be none'
+ assert field_desc_entry.name, name == 'FieldDescEntry.name should be the same as the name argument'
+ assert field_desc_entry.field_type == field_type, 'FieldDescEntry.type should be the same as the type argument'
+ assert field_desc_entry.size == size, 'FieldDescEntry.size should be the same as the size argument'
def test_create_importer(self):
"""
@@ -183,7 +182,7 @@
importer = EasyWorshipSongImport(mocked_manager, file_paths=[])
# THEN: The importer object should not be None
- self.assertIsNotNone(importer, 'Import should not be none')
+ assert importer is not None, 'Import should not be none'
def test_find_field_exists(self):
"""
@@ -201,7 +200,7 @@
for field_name in existing_fields:
# THEN: The item corresponding the index returned should have the same name attribute
- self.assertEqual(importer.field_descriptions[importer.db_find_field(field_name)].name, field_name)
+ assert importer.field_descriptions[importer.db_find_field(field_name)].name == field_name
def test_find_non_existing_field(self):
"""
@@ -236,7 +235,7 @@
# THEN: db_set_record_struct should return None and Struct should be called with a value representing
# the list of field descriptions
- self.assertIsNone(return_value, 'db_set_record_struct should return None')
+ assert return_value is None, 'db_set_record_struct should return None'
mocked_struct.Struct.assert_called_with('>50sHIB250s250s10sQ')
@patch('openlp.plugins.songs.lib.importers.easyworship.SongImport')
@@ -257,9 +256,8 @@
return_value = importer.db_get_field(field_index)
# THEN: db_get_field should return the known results
- self.assertEqual(return_value, result,
- 'db_get_field should return "%s" when called with "%s"' %
- (result, TEST_FIELDS[field_index]))
+ assert return_value == result, 'db_get_field should return "%s" when called with "%s"' % \
+ (result, TEST_FIELDS[field_index])
@patch('openlp.plugins.songs.lib.importers.easyworship.SongImport')
def test_get_memo_field(self, MockSongImport):
@@ -285,7 +283,7 @@
# THEN: db_get_field should return the appropriate value with the appropriate mocked objects being
# called
- self.assertEqual(importer.db_get_field(field_index), get_field_result)
+ assert importer.db_get_field(field_index) == get_field_result
for call in get_field_read_calls:
mocked_memo_file.read.assert_any_call(call)
for call in get_field_seek_calls:
@@ -330,7 +328,7 @@
mocked_stat.return_value.st_size = 0x7FF
# THEN: do_import should return None having called Path.stat()
- self.assertIsNone(importer.do_import(), 'do_import should return None when db_size is less than 0x800')
+ assert importer.do_import() is None, 'do_import should return None when db_size is less than 0x800'
mocked_stat.assert_called_once_with()
@patch('openlp.plugins.songs.lib.importers.easyworship.SongImport')
@@ -353,11 +351,10 @@
# THEN: do_import should return None having called closed the open files db and memo files.
for effect in struct_unpack_return_values:
- self.assertIsNone(importer.do_import(), 'do_import should return None when db_size is less than 0x800')
- self.assertEqual(mocked_open().close.call_count, 2,
- 'The open db and memo files should have been closed')
+ assert importer.do_import() is None, 'do_import should return None when db_size is less than 0x800'
+ assert mocked_open().close.call_count == 2, 'The open db and memo files should have been closed'
mocked_open().close.reset_mock()
- self.assertIs(mocked_open().seek.called, False, 'db_file.seek should not have been called.')
+ assert mocked_open().seek.called is False, 'db_file.seek should not have been called.'
@patch('openlp.plugins.songs.lib.importers.easyworship.SongImport')
@patch('openlp.plugins.songs.lib.importers.easyworship.Path.is_file', return_value=True)
@@ -383,7 +380,7 @@
mocked_retrieve_windows_encoding.return_value = False
# THEN: do_import should return None having called retrieve_windows_encoding with the correct encoding.
- self.assertIsNone(importer.do_import(), 'do_import should return None when db_size is less than 0x800')
+ assert importer.do_import() is None, 'do_import should return None when db_size is less than 0x800'
mocked_retrieve_windows_encoding.assert_any_call(encoding)
def test_db_file_import(self):
@@ -425,7 +422,7 @@
# THEN: do_import should return none, the song data should be as expected, and finish should have been
# called.
- self.assertIsNone(import_result, 'do_import should return None when it has completed')
+ assert import_result is None, 'do_import should return None when it has completed'
for song_data in SONG_TEST_DATA:
title = song_data['title']
author_calls = song_data['authors']
@@ -433,19 +430,18 @@
ccli_number = song_data['ccli_number']
add_verse_calls = song_data['verses']
verse_order_list = song_data['verse_order_list']
- self.assertIn(title, importer._title_assignment_list, 'title for %s should be "%s"' % (title, title))
+ assert title in importer._title_assignment_list, 'title for %s should be "%s"' % (title, title)
for author in author_calls:
mocked_add_author.assert_any_call(author)
if song_copyright:
- self.assertEqual(importer.copyright, song_copyright)
+ assert importer.copyright == song_copyright
if ccli_number:
- self.assertEqual(importer.ccli_number, ccli_number,
- 'ccli_number for %s should be %s' % (title, ccli_number))
+ assert importer.ccli_number == ccli_number, 'ccli_number for %s should be %s' % (title, ccli_number)
for verse_text, verse_tag in add_verse_calls:
mocked_add_verse.assert_any_call(verse_text, verse_tag)
if verse_order_list:
- self.assertEqual(importer.verse_order_list, verse_order_list,
- 'verse_order_list for %s should be %s' % (title, verse_order_list))
+ assert importer.verse_order_list == verse_order_list, \
+ 'verse_order_list for %s should be %s' % (title, verse_order_list)
mocked_finish.assert_called_with()
@patch('openlp.plugins.songs.lib.importers.easyworship.SongImport')
@@ -481,8 +477,8 @@
# THEN: do_import should return none, the song data should be as expected, and finish should have been
# called.
title = EWS_SONG_TEST_DATA['title']
- self.assertIsNone(import_result, 'do_import should return None when it has completed')
- self.assertIn(title, importer._title_assignment_list, 'title for should be "%s"' % title)
+ assert import_result is None, 'do_import should return None when it has completed'
+ assert title in importer._title_assignment_list, 'title for should be "%s"' % title
mocked_add_author.assert_any_call(EWS_SONG_TEST_DATA['authors'][0])
for verse_text, verse_tag in EWS_SONG_TEST_DATA['verses']:
mocked_add_verse.assert_any_call(verse_text, verse_tag)
@@ -505,4 +501,4 @@
importer.set_song_import_object('Test Author', b'Det som var fr\x86n begynnelsen')
# THEN: The import should fail
- self.assertEquals(importer.entry_error_log, 'Unexpected data formatting.', 'Import should fail')
+ assert importer.entry_error_log == 'Unexpected data formatting.', 'Import should fail'
=== modified file 'tests/functional/openlp_plugins/songs/test_foilpresenterimport.py'
--- tests/functional/openlp_plugins/songs/test_foilpresenterimport.py 2017-05-30 18:42:35 +0000
+++ tests/functional/openlp_plugins/songs/test_foilpresenterimport.py 2017-12-23 09:39:35 +0000
@@ -106,7 +106,7 @@
foil_presenter_instance = FoilPresenter(mocked_manager, mocked_song_import)
# THEN: The instance should not be None
- self.assertIsNotNone(foil_presenter_instance, 'foil_presenter instance should not be none')
+ assert foil_presenter_instance is not None, 'foil_presenter instance should not be none'
def test_no_xml(self):
"""
@@ -122,7 +122,7 @@
result = foil_presenter_instance.xml_to_song(arg)
# Then: xml_to_song should return False
- self.assertEqual(result, None, 'xml_to_song should return None when called with %s' % arg)
+ assert result is None, 'xml_to_song should return None when called with %s' % arg
def test_encoding_declaration_removal(self):
"""
@@ -169,6 +169,6 @@
result = foil_presenter_instance._process_lyrics(mock_foilpresenterfolie, mocked_song)
# THEN: _process_lyrics should return None and the song_import log_error method should have been called once
- self.assertIsNone(result)
+ assert result is None
self.mocked_song_import.log_error.assert_called_once_with('Element Text', 'Translated String')
self.process_lyrics_patcher.start()
=== modified file 'tests/functional/openlp_plugins/songs/test_lib.py'
--- tests/functional/openlp_plugins/songs/test_lib.py 2017-05-17 20:06:45 +0000
+++ tests/functional/openlp_plugins/songs/test_lib.py 2017-12-23 09:39:35 +0000
@@ -63,7 +63,7 @@
result = clean_string(dirty_string)
# THEN: The string should be cleaned up and lower-cased
- self.assertEqual(result, 'aint gonna find you there ', 'The string should be cleaned up properly')
+ assert result == 'aint gonna find you there ', 'The string should be cleaned up properly'
def test_clean_title(self):
"""
@@ -76,7 +76,7 @@
result = clean_title(dirty_string)
# THEN: The string should be cleaned up
- self.assertEqual(result, 'This is a dirty string', 'The title should be cleaned up properly: "%s"' % result)
+ assert result == 'This is a dirty string', 'The title should be cleaned up properly: "%s"' % result
def test_songs_probably_equal_same_song(self):
"""
@@ -275,7 +275,7 @@
new_chord = transpose_chord(chord, 1, 'english')
# THEN: The chord should be transposed up one note
- self.assertEqual(new_chord, 'C#', 'The chord should be transposed up.')
+ assert new_chord == 'C#', 'The chord should be transposed up.'
def test_transpose_chord_up_adv(self):
"""
@@ -288,7 +288,7 @@
new_chord = transpose_chord(chord, 1, 'english')
# THEN: The chord should be transposed up one note
- self.assertEqual(new_chord, '(C#/E)', 'The chord should be transposed up.')
+ assert new_chord == '(C#/E)', 'The chord should be transposed up.'
def test_transpose_chord_down(self):
"""
@@ -301,7 +301,7 @@
new_chord = transpose_chord(chord, -1, 'english')
# THEN: The chord should be transposed down one note
- self.assertEqual(new_chord, 'B', 'The chord should be transposed down.')
+ assert new_chord == 'B', 'The chord should be transposed down.'
def test_transpose_chord_error(self):
"""
@@ -314,8 +314,8 @@
# THEN: An exception should be raised
with self.assertRaises(ValueError) as err:
new_chord = transpose_chord(chord, -1, 'english')
- self.assertEqual(err.exception.args[0], '\'T\' is not in list',
- 'ValueError exception should have been thrown for invalid chord')
+ assert err.exception.args[0] == '\'T\' is not in list', \
+ 'ValueError exception should have been thrown for invalid chord'
@patch('openlp.plugins.songs.lib.transpose_verse')
@patch('openlp.plugins.songs.lib.Settings')
@@ -361,13 +361,13 @@
result = VerseType.translated_tag('v')
# THEN: The result should be "V"
- self.assertEqual(result, 'V', 'The result should be "V"')
+ assert result == 'V', 'The result should be "V"'
# WHEN: We run the translated_tag() method with a "chorus"
result = VerseType.translated_tag('c')
# THEN: The result should be "C"
- self.assertEqual(result, 'C', 'The result should be "C"')
+ assert result == 'C', 'The result should be "C"'
def test_translated_invalid_tag(self):
"""
@@ -381,7 +381,7 @@
result = VerseType.translated_tag('z')
# THEN: The result should be "O"
- self.assertEqual(result, 'O', 'The result should be "O", but was "%s"' % result)
+ assert result == 'O', 'The result should be "O", but was "%s"' % result
def test_translated_invalid_tag_with_specified_default(self):
"""
@@ -395,7 +395,7 @@
result = VerseType.translated_tag('q', VerseType.Bridge)
# THEN: The result should be "B"
- self.assertEqual(result, 'B', 'The result should be "B", but was "%s"' % result)
+ assert result == 'B', 'The result should be "B", but was "%s"' % result
def test_translated_invalid_tag_with_invalid_default(self):
"""
@@ -409,7 +409,7 @@
result = VerseType.translated_tag('q', 29)
# THEN: The result should be "O"
- self.assertEqual(result, 'O', 'The result should be "O", but was "%s"' % result)
+ assert result == 'O', 'The result should be "O", but was "%s"' % result
def test_translated_name(self):
"""
@@ -423,13 +423,13 @@
result = VerseType.translated_name('v')
# THEN: The result should be "Verse"
- self.assertEqual(result, 'Verse', 'The result should be "Verse"')
+ assert result == 'Verse', 'The result should be "Verse"'
# WHEN: We run the translated_name() method with a "chorus"
result = VerseType.translated_name('c')
# THEN: The result should be "Chorus"
- self.assertEqual(result, 'Chorus', 'The result should be "Chorus"')
+ assert result == 'Chorus', 'The result should be "Chorus"'
def test_translated_invalid_name(self):
"""
@@ -443,7 +443,7 @@
result = VerseType.translated_name('z')
# THEN: The result should be "Other"
- self.assertEqual(result, 'Other', 'The result should be "Other", but was "%s"' % result)
+ assert result == 'Other', 'The result should be "Other", but was "%s"' % result
def test_translated_invalid_name_with_specified_default(self):
"""
@@ -457,7 +457,7 @@
result = VerseType.translated_name('q', VerseType.Bridge)
# THEN: The result should be "Bridge"
- self.assertEqual(result, 'Bridge', 'The result should be "Bridge", but was "%s"' % result)
+ assert result == 'Bridge', 'The result should be "Bridge", but was "%s"' % result
def test_translated_invalid_name_with_invalid_default(self):
"""
@@ -471,7 +471,7 @@
result = VerseType.translated_name('q', 29)
# THEN: The result should be "Other"
- self.assertEqual(result, 'Other', 'The result should be "Other", but was "%s"' % result)
+ assert result == 'Other', 'The result should be "Other", but was "%s"' % result
def test_from_tag(self):
"""
@@ -485,7 +485,7 @@
result = VerseType.from_tag('v')
# THEN: The result should be VerseType.Verse
- self.assertEqual(result, VerseType.Verse, 'The result should be VerseType.Verse, but was "%s"' % result)
+ assert result == VerseType.Verse, 'The result should be VerseType.Verse, but was "%s"' % result
def test_from_tag_with_invalid_tag(self):
"""
@@ -499,7 +499,7 @@
result = VerseType.from_tag('w')
# THEN: The result should be VerseType.Other
- self.assertEqual(result, VerseType.Other, 'The result should be VerseType.Other, but was "%s"' % result)
+ assert result == VerseType.Other, 'The result should be VerseType.Other, but was "%s"' % result
def test_from_tag_with_specified_default(self):
"""
@@ -513,7 +513,7 @@
result = VerseType.from_tag('x', VerseType.Chorus)
# THEN: The result should be VerseType.Chorus
- self.assertEqual(result, VerseType.Chorus, 'The result should be VerseType.Chorus, but was "%s"' % result)
+ assert result == VerseType.Chorus, 'The result should be VerseType.Chorus, but was "%s"' % result
def test_from_tag_with_invalid_intdefault(self):
"""
@@ -527,7 +527,7 @@
result = VerseType.from_tag('m', 29)
# THEN: The result should be VerseType.Other
- self.assertEqual(result, VerseType.Other, 'The result should be VerseType.Other, but was "%s"' % result)
+ assert result == VerseType.Other, 'The result should be VerseType.Other, but was "%s"' % result
def test_from_tag_with_invalid_default(self):
"""
@@ -541,7 +541,7 @@
result = VerseType.from_tag('@', 'asdf')
# THEN: The result should be VerseType.Other
- self.assertEqual(result, VerseType.Other, 'The result should be VerseType.Other, but was "%s"' % result)
+ assert result == VerseType.Other, 'The result should be VerseType.Other, but was "%s"' % result
def test_from_tag_with_none_default(self):
"""
@@ -555,7 +555,7 @@
result = VerseType.from_tag('m', None)
# THEN: The result should be None
- self.assertIsNone(result, 'The result should be None, but was "%s"' % result)
+ assert result is None, 'The result should be None, but was "%s"' % result
@patch('openlp.plugins.songs.lib.VerseType.translated_tags', new_callable=PropertyMock, return_value=['x'])
def test_from_loose_input_with_invalid_input(self, mocked_translated_tags):
@@ -567,7 +567,7 @@
result = VerseType.from_loose_input('m', None)
# THEN: The result should be None
- self.assertIsNone(result, 'The result should be None, but was "%s"' % result)
+ assert result is None, 'The result should be None, but was "%s"' % result
@patch('openlp.plugins.songs.lib.VerseType.translated_tags', new_callable=PropertyMock, return_value=['x'])
def test_from_loose_input_with_valid_input(self, mocked_translated_tags):
@@ -579,4 +579,4 @@
result = VerseType.from_loose_input('v')
# THEN: The result should be a Verse
- self.assertEqual(result, VerseType.Verse, 'The result should be a verse, but was "%s"' % result)
+ assert result == VerseType.Verse, 'The result should be a verse, but was "%s"' % result
=== modified file 'tests/functional/openlp_plugins/songs/test_mediaitem.py'
--- tests/functional/openlp_plugins/songs/test_mediaitem.py 2017-10-07 07:05:07 +0000
+++ tests/functional/openlp_plugins/songs/test_mediaitem.py 2017-12-23 09:39:35 +0000
@@ -324,10 +324,9 @@
author_list = self.media_item.generate_footer(service_item, mock_song)
# THEN: I get the following Array returned
- self.assertEqual(service_item.raw_footer, ['My Song', 'Written by: my author', 'My copyright'],
- 'The array should be returned correctly with a song, one author and copyright')
- self.assertEqual(author_list, ['my author'],
- 'The author list should be returned correctly with one author')
+ assert service_item.raw_footer == ['My Song', 'Written by: my author', 'My copyright'], \
+ 'The array should be returned correctly with a song, one author and copyright'
+ assert author_list == ['my author'], 'The author list should be returned correctly with one author'
@patch(u'openlp.plugins.songs.lib.mediaitem.Settings')
def test_build_song_footer_one_author_hide_written_by(self, MockedSettings):
@@ -356,11 +355,10 @@
author_list = self.media_item.generate_footer(service_item, mock_song)
# THEN: I get the following Array returned
- self.assertEqual(service_item.raw_footer, ['My Song', 'my author', 'My copyright'],
- 'The array should be returned correctly with a song, one author and copyright,'
- 'text Written by should not be part of the text.')
- self.assertEqual(author_list, ['my author'],
- 'The author list should be returned correctly with one author')
+ assert service_item.raw_footer == ['My Song', 'my author', 'My copyright'], \
+ 'The array should be returned correctly with a song, one author and copyright, ' \
+ 'text Written by should not be part of the text.'
+ assert author_list == ['my author'], 'The author list should be returned correctly with one author'
def test_build_song_footer_two_authors(self):
"""
@@ -395,11 +393,11 @@
author_list = self.media_item.generate_footer(service_item, mock_song)
# THEN: I get the following Array returned
- self.assertEqual(service_item.raw_footer, ['My Song', 'Words: another author', 'Music: my author',
- 'Translation: translator', 'My copyright'],
- 'The array should be returned correctly with a song, two authors and copyright')
- self.assertEqual(author_list, ['another author', 'my author', 'translator'],
- 'The author list should be returned correctly with two authors')
+ assert service_item.raw_footer == ['My Song', 'Words: another author', 'Music: my author',
+ 'Translation: translator', 'My copyright'], \
+ 'The array should be returned correctly with a song, two authors and copyright'
+ assert author_list == ['another author', 'my author', 'translator'], \
+ 'The author list should be returned correctly with two authors'
def test_build_song_footer_base_ccli(self):
"""
@@ -416,16 +414,16 @@
self.media_item.generate_footer(service_item, mock_song)
# THEN: I get the following Array returned
- self.assertEqual(service_item.raw_footer, ['My Song', 'My copyright', 'CCLI License: 1234'],
- 'The array should be returned correctly with a song, an author, copyright and ccli')
+ assert service_item.raw_footer == ['My Song', 'My copyright', 'CCLI License: 1234'], \
+ 'The array should be returned correctly with a song, an author, copyright and ccli'
# WHEN: I amend the CCLI value
Settings().setValue('core/ccli number', '4321')
self.media_item.generate_footer(service_item, mock_song)
# THEN: I would get an amended footer string
- self.assertEqual(service_item.raw_footer, ['My Song', 'My copyright', 'CCLI License: 4321'],
- 'The array should be returned correctly with a song, an author, copyright and amended ccli')
+ assert service_item.raw_footer == ['My Song', 'My copyright', 'CCLI License: 4321'], \
+ 'The array should be returned correctly with a song, an author, copyright and amended ccli'
def test_build_song_footer_base_songbook(self):
"""
@@ -451,14 +449,14 @@
self.media_item.generate_footer(service_item, song)
# THEN: The songbook should not be in the footer
- self.assertEqual(service_item.raw_footer, ['My Song', 'My copyright'])
+ assert service_item.raw_footer == ['My Song', 'My copyright']
# WHEN: I activate the "display songbook" option
self.media_item.display_songbook = True
self.media_item.generate_footer(service_item, song)
# THEN: The songbook should be in the footer
- self.assertEqual(service_item.raw_footer, ['My Song', 'My copyright', 'My songbook #12, Thy songbook #502A'])
+ assert service_item.raw_footer == ['My Song', 'My copyright', 'My songbook #12, Thy songbook #502A']
def test_build_song_footer_copyright_enabled(self):
"""
@@ -475,7 +473,7 @@
self.media_item.generate_footer(service_item, mock_song)
# THEN: The copyright symbol should be in the footer
- self.assertEqual(service_item.raw_footer, ['My Song', '© My copyright'])
+ assert service_item.raw_footer == ['My Song', '© My copyright']
def test_build_song_footer_copyright_disabled(self):
"""
@@ -491,7 +489,7 @@
self.media_item.generate_footer(service_item, mock_song)
# THEN: The copyright symbol should not be in the footer
- self.assertEqual(service_item.raw_footer, ['My Song', 'My copyright'])
+ assert service_item.raw_footer == ['My Song', 'My copyright']
def test_authors_match(self):
"""
@@ -517,7 +515,7 @@
result = self.media_item._authors_match(song, authors_str)
# THEN: They should match
- self.assertTrue(result, "Authors should match")
+ assert result is True, "Authors should match"
def test_authors_dont_match(self):
# GIVEN: A song and a string with authors
@@ -540,7 +538,7 @@
result = self.media_item._authors_match(song, authors_str)
# THEN: They should not match
- self.assertFalse(result, "Authors should not match")
+ assert result is False, "Authors should not match"
def test_build_remote_search(self):
"""
@@ -559,7 +557,7 @@
search_results = self.media_item.search('My Song', False)
# THEN: The correct formatted results are returned
- self.assertEqual(search_results, [[123, 'My Song', 'My alternative']])
+ assert search_results == [[123, 'My Song', 'My alternative']]
@patch('openlp.plugins.songs.lib.mediaitem.Book')
@patch('openlp.plugins.songs.lib.mediaitem.SongBookEntry')
@@ -590,4 +588,4 @@
mocked_or.assert_called_once_with('%jesus%', '%jesus%', '%jesus%', '%jesus%', '%jesus%')
self.mocked_plugin.manager.session.query.assert_called_once_with(MockedSong)
- self.assertEqual(self.mocked_plugin.manager.session.query.mock_calls[4][0], '().join().join().filter().all')
+ assert self.mocked_plugin.manager.session.query.mock_calls[4][0] == '().join().join().filter().all'
=== modified file 'tests/functional/openlp_plugins/songs/test_mediashout.py'
--- tests/functional/openlp_plugins/songs/test_mediashout.py 2017-10-10 02:29:56 +0000
+++ tests/functional/openlp_plugins/songs/test_mediashout.py 2017-12-23 09:39:35 +0000
@@ -54,7 +54,7 @@
importer = MediaShoutImport(MagicMock(), file_path='mediashout.db')
# THEN: It should not be None
- self.assertIsNotNone(importer)
+ assert importer is not None
@patch('openlp.plugins.songs.lib.importers.mediashout.pyodbc')
def test_do_import_fails_to_connect(self, mocked_pyodbc):
@@ -112,7 +112,7 @@
call('SELECT Name FROM Groups INNER JOIN SongGroups ON SongGroups.GroupId = Groups.GroupId '
'WHERE SongGroups.Record = ?', 1.0)
]
- self.assertEqual(expected_execute_calls, mocked_cursor.execute.call_args_list)
+ assert expected_execute_calls == mocked_cursor.execute.call_args_list
mocked_process_song.assert_called_once_with(song, [verse], [play_order], [theme, group])
@patch('openlp.plugins.songs.lib.importers.mediashout.pyodbc')
@@ -172,16 +172,16 @@
# THEN: It should be added to the database
mocked_set_defaults.assert_called_once_with()
- self.assertEqual('Amazing Grace', importer.title)
+ assert 'Amazing Grace' == importer.title
mocked_parse_author.assert_called_once_with('William Wilberforce')
mocked_add_copyright.assert_called_once_with('Public Domain')
- self.assertEqual('Great old hymn', importer.comments)
- self.assertEqual(['Grace', 'Hymns'], importer.topics)
- self.assertEqual('Hymns', importer.song_book_name)
- self.assertEqual('', importer.song_number)
+ assert 'Great old hymn' == importer.comments
+ assert ['Grace', 'Hymns'] == importer.topics
+ assert 'Hymns' == importer.song_book_name
+ assert '' == importer.song_number
mocked_add_verse.assert_called_once_with(
'Amazing grace, how sweet the sound\nThat saved a wretch like me', 'V1')
- self.assertEqual(['V1'], importer.verse_order_list)
+ assert ['V1'] == importer.verse_order_list
mocked_finish.assert_called_once_with()
def test_process_song_with_song_number(self):
@@ -214,14 +214,14 @@
# THEN: It should be added to the database
mocked_set_defaults.assert_called_once_with()
- self.assertEqual('Amazing Grace', importer.title)
+ assert 'Amazing Grace' == importer.title
mocked_parse_author.assert_called_once_with('William Wilberforce')
mocked_add_copyright.assert_called_once_with('Public Domain')
- self.assertEqual('Great old hymn', importer.comments)
- self.assertEqual(['Grace', 'Hymns'], importer.topics)
- self.assertEqual('Hymns', importer.song_book_name)
- self.assertEqual('2', importer.song_number)
+ assert 'Great old hymn' == importer.comments
+ assert ['Grace', 'Hymns'] == importer.topics
+ assert 'Hymns' == importer.song_book_name
+ assert '2' == importer.song_number
mocked_add_verse.assert_called_once_with(
'Amazing grace, how sweet the sound\nThat saved a wretch like me', 'V1')
- self.assertEqual(['V1'], importer.verse_order_list)
+ assert ['V1'], importer.verse_order_list
mocked_finish.assert_called_once_with()
=== modified file 'tests/functional/openlp_plugins/songs/test_openlpimporter.py'
--- tests/functional/openlp_plugins/songs/test_openlpimporter.py 2017-10-10 02:29:56 +0000
+++ tests/functional/openlp_plugins/songs/test_openlpimporter.py 2017-12-23 09:39:35 +0000
@@ -51,7 +51,7 @@
importer = OpenLPSongImport(mocked_manager, file_paths=[])
# THEN: The importer object should not be None
- self.assertIsNotNone(importer, 'Import should not be none')
+ assert importer is not None, 'Import should not be none'
def test_invalid_import_source(self):
"""
@@ -70,6 +70,6 @@
importer.import_source = source
# THEN: do_import should return none and the progress bar maximum should not be set.
- self.assertIsNone(importer.do_import(), 'do_import should return None when import_source is not a list')
- self.assertEqual(mocked_import_wizard.progress_bar.setMaximum.called, False,
- 'setMaximum on import_wizard.progress_bar should not have been called')
+ assert importer.do_import() is None, 'do_import should return None when import_source is not a list'
+ assert mocked_import_wizard.progress_bar.setMaximum.called is False, \
+ 'setMaximum on import_wizard.progress_bar should not have been called'
=== modified file 'tests/functional/openlp_plugins/songs/test_openlyricsexport.py'
--- tests/functional/openlp_plugins/songs/test_openlyricsexport.py 2017-11-20 21:57:34 +0000
+++ tests/functional/openlp_plugins/songs/test_openlyricsexport.py 2017-12-23 09:39:35 +0000
@@ -72,9 +72,7 @@
ol_export.do_export()
# THEN: The exporter should have created 2 files
- self.assertTrue((self.temp_folder /
- '{title} ({display_name}).xml'.format(
- title=song.title, display_name=author.display_name)).exists())
- self.assertTrue((self.temp_folder /
- '{title} ({display_name})-1.xml'.format(
- title=song.title, display_name=author.display_name)).exists())
+ assert (self.temp_folder / '{title} ({display_name}).xml'.format(
+ title=song.title, display_name=author.display_name)).exists() is True
+ assert (self.temp_folder / '{title} ({display_name})-1.xml'.format(
+ title=song.title, display_name=author.display_name)).exists() is True
=== modified file 'tests/functional/openlp_plugins/songs/test_openlyricsimport.py'
--- tests/functional/openlp_plugins/songs/test_openlyricsimport.py 2017-10-10 02:29:56 +0000
+++ tests/functional/openlp_plugins/songs/test_openlyricsimport.py 2017-12-23 09:39:35 +0000
@@ -114,7 +114,7 @@
importer = OpenLyricsImport(mocked_manager, file_paths=[])
# THEN: The importer should be an instance of SongImport
- self.assertIsInstance(importer, SongImport)
+ assert isinstance(importer, SongImport)
def test_file_import(self):
"""
@@ -134,7 +134,7 @@
importer.do_import()
# THEN: The xml_to_song() method should have been called
- self.assertTrue(importer.open_lyrics.xml_to_song.called)
+ assert importer.open_lyrics.xml_to_song.called is True
def test_process_formatting_tags(self):
"""
@@ -153,9 +153,8 @@
ol._process_formatting_tags(song_xml, False)
# THEN: New tags should have been saved
- self.assertListEqual(json.loads(json.dumps(result_tags)),
- json.loads(str(Settings().value('formattingTags/html_tags'))),
- 'The formatting tags should contain both the old and the new')
+ assert json.loads(json.dumps(result_tags)) == json.loads(str(Settings().value('formattingTags/html_tags'))), \
+ 'The formatting tags should contain both the old and the new'
def test_process_author(self):
"""
@@ -173,8 +172,8 @@
ol._process_authors(properties_xml, mocked_song)
# THEN: add_author should have been called twice
- self.assertEquals(mocked_song.method_calls[0][1][1], 'words+music')
- self.assertEquals(mocked_song.method_calls[1][1][1], 'words')
+ assert mocked_song.method_calls[0][1][1] == 'words+music'
+ assert mocked_song.method_calls[1][1][1] == 'words'
def test_process_songbooks(self):
"""
@@ -192,5 +191,5 @@
ol._process_songbooks(properties_xml, mocked_song)
# THEN: add_songbook_entry should have been called twice
- self.assertEquals(mocked_song.method_calls[0][1][1], '48')
- self.assertEquals(mocked_song.method_calls[1][1][1], '445 A')
+ assert mocked_song.method_calls[0][1][1] == '48'
+ assert mocked_song.method_calls[1][1][1] == '445 A'
=== modified file 'tests/functional/openlp_plugins/songs/test_openoffice.py'
--- tests/functional/openlp_plugins/songs/test_openoffice.py 2017-11-30 22:46:03 +0000
+++ tests/functional/openlp_plugins/songs/test_openoffice.py 2017-12-23 09:39:35 +0000
@@ -59,7 +59,7 @@
importer = OpenOfficeImport(mocked_manager, file_paths=[])
# THEN: The importer object should not be None
- self.assertIsNotNone(importer, 'Import should not be none')
+ assert importer is not None, 'Import should not be none'
@patch('openlp.plugins.songs.lib.importers.openoffice.SongImport')
def test_close_ooo_file(self, mocked_songimport):
@@ -76,4 +76,4 @@
importer.close_ooo_file()
# THEN: The document attribute should be None even if an exception is raised')
- self.assertIsNone(importer.document, 'Document should be None even if an exception is raised')
+ assert importer.document is None, 'Document should be None even if an exception is raised'
=== modified file 'tests/functional/openlp_plugins/songs/test_opensongimport.py'
--- tests/functional/openlp_plugins/songs/test_opensongimport.py 2017-10-10 02:29:56 +0000
+++ tests/functional/openlp_plugins/songs/test_opensongimport.py 2017-12-23 09:39:35 +0000
@@ -87,7 +87,7 @@
importer = OpenSongImport(mocked_manager, file_paths=[])
# THEN: The importer object should not be None
- self.assertIsNotNone(importer, 'Import should not be none')
+ assert importer is not None, 'Import should not be none'
def test_invalid_import_source(self):
"""
@@ -106,9 +106,9 @@
importer.import_source = source
# THEN: do_import should return none and the progress bar maximum should not be set.
- self.assertIsNone(importer.do_import(), 'do_import should return None when import_source is not a list')
- self.assertEqual(mocked_import_wizard.progress_bar.setMaximum.called, False,
- 'setMaximum on import_wizard.progress_bar should not have been called')
+ assert importer.do_import() is None, 'do_import should return None when import_source is not a list'
+ assert mocked_import_wizard.progress_bar.setMaximum.called is False, \
+ 'setMaximum on import_wizard.progress_bar should not have been called'
def test_valid_import_source(self):
"""
@@ -127,6 +127,6 @@
# THEN: do_import should return none and the progress bar setMaximum should be called with the length of
# import_source.
- self.assertIsNone(importer.do_import(), 'do_import should return None when import_source is a list '
- 'and stop_import_flag is True')
+ assert importer.do_import() is None, \
+ 'do_import should return None when import_source is a list and stop_import_flag is True'
mocked_import_wizard.progress_bar.setMaximum.assert_called_with(len(importer.import_source))
=== modified file 'tests/functional/openlp_plugins/songs/test_opsproimport.py'
--- tests/functional/openlp_plugins/songs/test_opsproimport.py 2017-10-10 02:29:56 +0000
+++ tests/functional/openlp_plugins/songs/test_opsproimport.py 2017-12-23 09:39:35 +0000
@@ -89,7 +89,7 @@
importer = OPSProImport(mocked_manager, file_paths=[])
# THEN: The importer object should not be None
- self.assertIsNotNone(importer, 'Import should not be none')
+ assert importer is not None, 'Import should not be none'
@patch('openlp.plugins.songs.lib.importers.opspro.SongImport')
def test_detect_chorus(self, mocked_songimport):
@@ -108,8 +108,8 @@
# THEN: The imported data should look like expected
result_file = open(os.path.join(TEST_PATH, 'You are so faithful.json'), 'rb')
result_data = json.loads(result_file.read().decode())
- self.assertListEqual(importer.verses, _get_item(result_data, 'verses'))
- self.assertListEqual(importer.verse_order_list_generated, _get_item(result_data, 'verse_order_list'))
+ assert importer.verses == _get_item(result_data, 'verses')
+ assert importer.verse_order_list_generated == _get_item(result_data, 'verse_order_list')
@patch('openlp.plugins.songs.lib.importers.opspro.SongImport')
def test_join_and_split(self, mocked_songimport):
@@ -128,8 +128,8 @@
# THEN: The imported data should look like expected
result_file = open(os.path.join(TEST_PATH, 'Amazing Grace.json'), 'rb')
result_data = json.loads(result_file.read().decode())
- self.assertListEqual(importer.verses, _get_item(result_data, 'verses'))
- self.assertListEqual(importer.verse_order_list_generated, _get_item(result_data, 'verse_order_list'))
+ assert importer.verses == _get_item(result_data, 'verses')
+ assert importer.verse_order_list_generated == _get_item(result_data, 'verse_order_list')
@patch('openlp.plugins.songs.lib.importers.opspro.SongImport')
def test_trans_off_tag(self, mocked_songimport):
@@ -148,8 +148,8 @@
# THEN: The imported data should look like expected
result_file = open(os.path.join(TEST_PATH, 'Amazing Grace.json'), 'rb')
result_data = json.loads(result_file.read().decode())
- self.assertListEqual(importer.verses, _get_item(result_data, 'verses'))
- self.assertListEqual(importer.verse_order_list_generated, _get_item(result_data, 'verse_order_list'))
+ assert importer.verses == _get_item(result_data, 'verses')
+ assert importer.verse_order_list_generated == _get_item(result_data, 'verse_order_list')
@patch('openlp.plugins.songs.lib.importers.opspro.SongImport')
def test_trans_tag(self, mocked_songimport):
@@ -168,5 +168,5 @@
# THEN: The imported data should look like expected
result_file = open(os.path.join(TEST_PATH, 'Amazing Grace3.json'), 'rb')
result_data = json.loads(result_file.read().decode())
- self.assertListEqual(importer.verses, _get_item(result_data, 'verses'))
- self.assertListEqual(importer.verse_order_list_generated, _get_item(result_data, 'verse_order_list'))
+ assert importer.verses == _get_item(result_data, 'verses')
+ assert importer.verse_order_list_generated == _get_item(result_data, 'verse_order_list')
=== modified file 'tests/functional/openlp_plugins/songs/test_songbeamerimport.py'
--- tests/functional/openlp_plugins/songs/test_songbeamerimport.py 2017-10-10 02:29:56 +0000
+++ tests/functional/openlp_plugins/songs/test_songbeamerimport.py 2017-12-23 09:39:35 +0000
@@ -99,7 +99,7 @@
importer = SongBeamerImport(mocked_manager, file_paths=[])
# THEN: The importer object should not be None
- self.assertIsNotNone(importer, 'Import should not be none')
+ assert importer is not None, 'Import should not be none'
def test_invalid_import_source(self):
"""
@@ -115,10 +115,10 @@
self.importer.import_source = source
# THEN: do_import should return none and the progress bar maximum should not be set.
- self.assertIsNone(self.importer.do_import(),
- 'do_import should return None when import_source is not a list')
- self.assertEqual(mocked_import_wizard.progress_bar.setMaximum.called, False,
- 'setMaxium on import_wizard.progress_bar should not have been called')
+ assert self.importer.do_import() is None, \
+ 'do_import should return None when import_source is not a list'
+ assert mocked_import_wizard.progress_bar.setMaximum.called is False, \
+ 'setMaxium on import_wizard.progress_bar should not have been called'
def test_valid_import_source(self):
"""
@@ -134,8 +134,8 @@
# THEN: do_import should return none and the progress bar setMaximum should be called with the length of
# import_source.
- self.assertIsNone(self.importer.do_import(),
- 'do_import should return None when import_source is a list and stop_import_flag is True')
+ assert self.importer.do_import() is None, \
+ 'do_import should return None when import_source is a list and stop_import_flag is True'
mocked_import_wizard.progress_bar.setMaximum.assert_called_with(len(self.importer.import_source))
def test_check_verse_marks(self):
@@ -149,8 +149,8 @@
# WHEN: line is being checked for verse marks
result = self.importer.check_verse_marks(line)
# THEN: we should get back true and c as self.importer.current_verse_type
- self.assertTrue(result, 'Versemark for <Refrain> should be found, value true')
- self.assertEqual(self.importer.current_verse_type, 'c', '<Refrain> should be interpreted as <c>')
+ assert result is True, 'Versemark for <Refrain> should be found, value true'
+ assert self.importer.current_verse_type == 'c', '<Refrain> should be interpreted as <c>'
# GIVEN: line with unnumbered verse-type and trailing space
line = 'ReFrain '
@@ -158,8 +158,8 @@
# WHEN: line is being checked for verse marks
result = self.importer.check_verse_marks(line)
# THEN: we should get back true and c as self.importer.current_verse_type
- self.assertTrue(result, 'Versemark for <ReFrain > should be found, value true')
- self.assertEqual(self.importer.current_verse_type, 'c', '<ReFrain > should be interpreted as <c>')
+ assert result is True, 'Versemark for <ReFrain > should be found, value true'
+ assert self.importer.current_verse_type == 'c', '<ReFrain > should be interpreted as <c>'
# GIVEN: line with numbered verse-type
line = 'VersE 1'
@@ -167,8 +167,8 @@
# WHEN: line is being checked for verse marks
result = self.importer.check_verse_marks(line)
# THEN: we should get back true and v1 as self.importer.current_verse_type
- self.assertTrue(result, 'Versemark for <VersE 1> should be found, value true')
- self.assertEqual(self.importer.current_verse_type, 'v1', u'<VersE 1> should be interpreted as <v1>')
+ assert result is True, 'Versemark for <VersE 1> should be found, value true'
+ assert self.importer.current_verse_type == 'v1', u'<VersE 1> should be interpreted as <v1>'
# GIVEN: line with special unnumbered verse-mark (used in Songbeamer to allow usage of non-supported tags)
line = '$$M=special'
@@ -176,8 +176,8 @@
# WHEN: line is being checked for verse marks
result = self.importer.check_verse_marks(line)
# THEN: we should get back true and o as self.importer.current_verse_type
- self.assertTrue(result, 'Versemark for <$$M=special> should be found, value true')
- self.assertEqual(self.importer.current_verse_type, 'o', u'<$$M=special> should be interpreted as <o>')
+ assert result is True, 'Versemark for <$$M=special> should be found, value true'
+ assert self.importer.current_verse_type == 'o', u'<$$M=special> should be interpreted as <o>'
# GIVEN: line with song-text with 3 words
line = 'Jesus my saviour'
@@ -185,9 +185,8 @@
# WHEN: line is being checked for verse marks
result = self.importer.check_verse_marks(line)
# THEN: we should get back false and none as self.importer.current_verse_type
- self.assertFalse(result, 'No versemark for <Jesus my saviour> should be found, value false')
- self.assertIsNone(self.importer.current_verse_type,
- '<Jesus my saviour> should be interpreted as none versemark')
+ assert result is False, 'No versemark for <Jesus my saviour> should be found, value false'
+ assert self.importer.current_verse_type is None, '<Jesus my saviour> should be interpreted as none versemark'
# GIVEN: line with song-text with 2 words
line = 'Praise him'
@@ -195,8 +194,8 @@
# WHEN: line is being checked for verse marks
result = self.importer.check_verse_marks(line)
# THEN: we should get back false and none as self.importer.current_verse_type
- self.assertFalse(result, 'No versemark for <Praise him> should be found, value false')
- self.assertIsNone(self.importer.current_verse_type, '<Praise him> should be interpreted as none versemark')
+ assert result is False, 'No versemark for <Praise him> should be found, value false'
+ assert self.importer.current_verse_type is None, '<Praise him> should be interpreted as none versemark'
# GIVEN: line with only a space (could occur, nothing regular)
line = ' '
@@ -204,8 +203,8 @@
# WHEN: line is being checked for verse marks
result = self.importer.check_verse_marks(line)
# THEN: we should get back false and none as self.importer.current_verse_type
- self.assertFalse(result, 'No versemark for < > should be found, value false')
- self.assertIsNone(self.importer.current_verse_type, '< > should be interpreted as none versemark')
+ assert result is False, 'No versemark for < > should be found, value false'
+ assert self.importer.current_verse_type is None, '< > should be interpreted as none versemark'
# GIVEN: blank line (could occur, nothing regular)
line = ''
@@ -213,8 +212,8 @@
# WHEN: line is being checked for verse marks
result = self.importer.check_verse_marks(line)
# THEN: we should get back false and none as self.importer.current_verse_type
- self.assertFalse(result, 'No versemark for <> should be found, value false')
- self.assertIsNone(self.importer.current_verse_type, '<> should be interpreted as none versemark')
+ assert result is False, 'No versemark for <> should be found, value false'
+ assert self.importer.current_verse_type is None, '<> should be interpreted as none versemark'
def test_verse_marks_defined_in_lowercase(self):
"""
@@ -223,4 +222,4 @@
# GIVEN: SongBeamber MarkTypes
for tag in SongBeamerTypes.MarkTypes.keys():
# THEN: tag should be defined in lowercase
- self.assertEquals(tag, tag.lower(), 'Tags should be defined in lowercase')
+ assert tag == tag.lower(), 'Tags should be defined in lowercase'
=== modified file 'tests/functional/openlp_plugins/songs/test_songformat.py'
--- tests/functional/openlp_plugins/songs/test_songformat.py 2016-01-10 16:01:43 +0000
+++ tests/functional/openlp_plugins/songs/test_songformat.py 2017-12-23 09:39:35 +0000
@@ -39,8 +39,8 @@
# GIVEN: The SongFormat class
# WHEN: Retrieving the format list
# THEN: All SongFormats should be returned
- self.assertEquals(len(SongFormat.get_format_list()), len(SongFormat.__attributes__),
- "The returned SongFormats don't match the stored ones")
+ assert len(SongFormat.get_format_list()) == len(SongFormat.__attributes__), \
+ "The returned SongFormats don't match the stored ones"
def test_get_attributed_no_attributes(self):
"""
@@ -50,8 +50,8 @@
# WHEN: Retrieving all attributes of a SongFormat
for song_format in SongFormat.get_format_list():
# THEN: All attributes associated with the SongFormat should be returned
- self.assertEquals(SongFormat.get(song_format), SongFormat.__attributes__[song_format],
- "The returned attributes don't match the stored ones")
+ assert SongFormat.get(song_format) == SongFormat.__attributes__[song_format], \
+ "The returned attributes don't match the stored ones"
def test_get_attributed_single_attribute(self):
"""
@@ -62,14 +62,14 @@
# WHEN: Retrieving an attribute that overrides the default values
for attribute in SongFormat.get(song_format).keys():
# THEN: Return the attribute
- self.assertEquals(SongFormat.get(song_format, attribute), SongFormat.get(song_format)[attribute],
- "The returned attribute doesn't match the stored one")
+ assert SongFormat.get(song_format, attribute) == SongFormat.get(song_format)[attribute], \
+ "The returned attribute doesn't match the stored one"
# WHEN: Retrieving an attribute that was not overridden
for attribute in SongFormat.__defaults__.keys():
if attribute not in SongFormat.get(song_format).keys():
# THEN: Return the default value
- self.assertEquals(SongFormat.get(song_format, attribute), SongFormat.__defaults__[attribute],
- "The returned attribute does not match the default values stored")
+ assert SongFormat.get(song_format, attribute) == SongFormat.__defaults__[attribute], \
+ "The returned attribute does not match the default values stored"
def test_get_attributed_multiple_attributes(self):
"""
@@ -79,9 +79,8 @@
# WHEN: Retrieving multiple attributes at the same time
for song_format in SongFormat.get_format_list():
# THEN: Return all attributes that were specified
- self.assertEquals(len(SongFormat.get(song_format, 'canDisable', 'availability')), 2,
- "Did not return the correct number of attributes"
- " when retrieving multiple attributes at once")
+ assert len(SongFormat.get(song_format, 'canDisable', 'availability')) == 2, \
+ "Did not return the correct number of attributes when retrieving multiple attributes at once"
def test_get_format_list_returns_ordered_list(self):
"""
@@ -91,5 +90,5 @@
# GIVEN: The SongFormat class
# WHEN: Retrieving all formats
# THEN: The returned list should be sorted according to the ordering defined in SongFormat
- self.assertEquals(sorted(SongFormat.get_format_list()), SongFormat.get_format_list(),
- "The list returned should be sorted according to the ordering in SongFormat")
+ assert sorted(SongFormat.get_format_list()) == SongFormat.get_format_list(), \
+ "The list returned should be sorted according to the ordering in SongFormat"
=== modified file 'tests/functional/openlp_plugins/songs/test_songselect.py'
--- tests/functional/openlp_plugins/songs/test_songselect.py 2017-10-29 06:01:25 +0000
+++ tests/functional/openlp_plugins/songs/test_songselect.py 2017-12-23 09:39:35 +0000
@@ -57,10 +57,10 @@
importer = SongSelectImport(None)
# THEN: The object should have the correct properties
- self.assertIsNone(importer.db_manager, 'The db_manager should be None')
- self.assertIsNotNone(importer.html_parser, 'There should be a valid html_parser object')
- self.assertIsNotNone(importer.opener, 'There should be a valid opener object')
- self.assertEqual(1, mocked_build_opener.call_count, 'The build_opener method should have been called once')
+ assert importer.db_manager is None, 'The db_manager should be None'
+ assert importer.html_parser is not None, 'There should be a valid html_parser object'
+ assert importer.opener is not None, 'There should be a valid opener object'
+ assert 1 == mocked_build_opener.call_count, 'The build_opener method should have been called once'
@patch('openlp.plugins.songs.lib.songselect.build_opener')
@patch('openlp.plugins.songs.lib.songselect.BeautifulSoup')
@@ -83,11 +83,11 @@
result = importer.login('username', 'password', mock_callback)
# THEN: callback was called 3 times, open was called twice, find was called twice, and False was returned
- self.assertEqual(3, mock_callback.call_count, 'callback should have been called 3 times')
- self.assertEqual(2, mocked_login_page.find.call_count, 'find should have been called twice')
- self.assertEqual(1, mocked_posted_page.find.call_count, 'find should have been called once')
- self.assertEqual(2, mocked_opener.open.call_count, 'opener should have been called twice')
- self.assertFalse(result, 'The login method should have returned False')
+ assert 3 == mock_callback.call_count, 'callback should have been called 3 times'
+ assert 2 == mocked_login_page.find.call_count, 'find should have been called twice'
+ assert 1 == mocked_posted_page.find.call_count, 'find should have been called once'
+ assert 2 == mocked_opener.open.call_count, 'opener should have been called twice'
+ assert result is False, 'The login method should have returned False'
@patch('openlp.plugins.songs.lib.songselect.build_opener')
def test_login_except(self, mocked_build_opener):
@@ -103,8 +103,8 @@
result = importer.login('username', 'password', mock_callback)
# THEN: callback was called 1 time and False was returned
- self.assertEqual(1, mock_callback.call_count, 'callback should have been called 1 times')
- self.assertFalse(result, 'The login method should have returned False')
+ assert 1 == mock_callback.call_count, 'callback should have been called 1 times'
+ assert result is False, 'The login method should have returned False'
@patch('openlp.plugins.songs.lib.songselect.build_opener')
@patch('openlp.plugins.songs.lib.songselect.BeautifulSoup')
@@ -127,11 +127,11 @@
result = importer.login('username', 'password', mock_callback)
# THEN: callback was called 3 times, open was called twice, find was called twice, and True was returned
- self.assertEqual(3, mock_callback.call_count, 'callback should have been called 3 times')
- self.assertEqual(2, mocked_login_page.find.call_count, 'find should have been called twice on the login page')
- self.assertEqual(1, mocked_posted_page.find.call_count, 'find should have been called once on the posted page')
- self.assertEqual(2, mocked_opener.open.call_count, 'opener should have been called twice')
- self.assertTrue(result, 'The login method should have returned True')
+ assert 3 == mock_callback.call_count, 'callback should have been called 3 times'
+ assert 2 == mocked_login_page.find.call_count, 'find should have been called twice on the login page'
+ assert 1 == mocked_posted_page.find.call_count, 'find should have been called once on the posted page'
+ assert 2 == mocked_opener.open.call_count, 'opener should have been called twice'
+ assert result is True, 'The login method should have returned True'
@patch('openlp.plugins.songs.lib.songselect.build_opener')
@patch('openlp.plugins.songs.lib.songselect.BeautifulSoup')
@@ -156,11 +156,11 @@
result = importer.login('username', 'password', mock_callback)
# THEN: callback was called 3 times, open was called twice, find was called twice, and True was returned
- self.assertEqual(3, mock_callback.call_count, 'callback should have been called 3 times')
- self.assertEqual(2, mocked_login_page.find.call_count, 'find should have been called twice on the login page')
- self.assertEqual(1, mocked_posted_page.find.call_count, 'find should have been called once on the posted page')
- self.assertEqual('https://profile.ccli.com/do/login', mocked_opener.open.call_args_list[1][0][0])
- self.assertTrue(result, 'The login method should have returned True')
+ assert 3 == mock_callback.call_count, 'callback should have been called 3 times'
+ assert 2 == mocked_login_page.find.call_count, 'find should have been called twice on the login page'
+ assert 1 == mocked_posted_page.find.call_count, 'find should have been called once on the posted page'
+ assert 'https://profile.ccli.com/do/login', mocked_opener.open.call_args_list[1][0][0]
+ assert result is True, 'The login method should have returned True'
@patch('openlp.plugins.songs.lib.songselect.build_opener')
def test_logout(self, mocked_build_opener):
@@ -176,7 +176,7 @@
importer.logout()
# THEN: The opener is called once with the logout url
- self.assertEqual(1, mocked_opener.open.call_count, 'opener should have been called once')
+ assert 1 == mocked_opener.open.call_count, 'opener should have been called once'
mocked_opener.open.assert_called_with(LOGOUT_URL)
@patch('openlp.plugins.songs.lib.songselect.build_opener')
@@ -198,11 +198,11 @@
results = importer.search('text', 1000, mock_callback)
# THEN: callback was never called, open was called once, find_all was called once, an empty list returned
- self.assertEqual(0, mock_callback.call_count, 'callback should not have been called')
- self.assertEqual(1, mocked_opener.open.call_count, 'open should have been called once')
- self.assertEqual(1, mocked_results_page.find_all.call_count, 'find_all should have been called once')
+ assert 0 == mock_callback.call_count, 'callback should not have been called'
+ assert 1 == mocked_opener.open.call_count, 'open should have been called once'
+ assert 1 == mocked_results_page.find_all.call_count, 'find_all should have been called once'
mocked_results_page.find_all.assert_called_with('div', 'song-result')
- self.assertEqual([], results, 'The search method should have returned an empty list')
+ assert [] == results, 'The search method should have returned an empty list'
@patch('openlp.plugins.songs.lib.songselect.build_opener')
@patch('openlp.plugins.songs.lib.songselect.BeautifulSoup')
@@ -238,15 +238,15 @@
results = importer.search('text', 1000, mock_callback)
# THEN: callback was never called, open was called once, find_all was called once, an empty list returned
- self.assertEqual(2, mock_callback.call_count, 'callback should have been called twice')
- self.assertEqual(2, mocked_opener.open.call_count, 'open should have been called twice')
- self.assertEqual(2, mocked_results_page.find_all.call_count, 'find_all should have been called twice')
+ assert 2 == mock_callback.call_count, 'callback should have been called twice'
+ assert 2 == mocked_opener.open.call_count, 'open should have been called twice'
+ assert 2 == mocked_results_page.find_all.call_count, 'find_all should have been called twice'
mocked_results_page.find_all.assert_called_with('div', 'song-result')
expected_list = [
{'title': 'Title 1', 'authors': ['James', 'John'], 'link': BASE_URL + '/url1'},
{'title': 'Title 2', 'authors': ['Philip'], 'link': BASE_URL + '/url2'}
]
- self.assertListEqual(expected_list, results, 'The search method should have returned two songs')
+ assert expected_list == results, 'The search method should have returned two songs'
@patch('openlp.plugins.songs.lib.songselect.build_opener')
@patch('openlp.plugins.songs.lib.songselect.BeautifulSoup')
@@ -289,13 +289,13 @@
results = importer.search('text', 2, mock_callback)
# THEN: callback was called twice, open was called twice, find_all was called twice, max results returned
- self.assertEqual(2, mock_callback.call_count, 'callback should have been called twice')
- self.assertEqual(2, mocked_opener.open.call_count, 'open should have been called twice')
- self.assertEqual(2, mocked_results_page.find_all.call_count, 'find_all should have been called twice')
+ assert 2 == mock_callback.call_count, 'callback should have been called twice'
+ assert 2 == mocked_opener.open.call_count, 'open should have been called twice'
+ assert 2 == mocked_results_page.find_all.call_count, 'find_all should have been called twice'
mocked_results_page.find_all.assert_called_with('div', 'song-result')
expected_list = [{'title': 'Title 1', 'authors': ['James', 'John'], 'link': BASE_URL + '/url1'},
{'title': 'Title 2', 'authors': ['Philip'], 'link': BASE_URL + '/url2'}]
- self.assertListEqual(expected_list, results, 'The search method should have returned two songs')
+ assert expected_list == results, 'The search method should have returned two songs'
@patch('openlp.plugins.songs.lib.songselect.build_opener')
@patch('openlp.plugins.songs.lib.songselect.BeautifulSoup')
@@ -311,7 +311,7 @@
importer.stop()
# THEN: Searching should have stopped
- self.assertFalse(importer.run_search, 'Searching should have been stopped')
+ assert importer.run_search is False, 'Searching should have been stopped'
@patch('openlp.plugins.songs.lib.songselect.build_opener')
def test_get_song_page_raises_exception(self, mocked_build_opener):
@@ -330,7 +330,7 @@
# THEN: The callback should have been called once and None should be returned
mocked_callback.assert_called_with()
- self.assertIsNone(result, 'The get_song() method should have returned None')
+ assert result is None, 'The get_song() method should have returned None'
@patch('openlp.plugins.songs.lib.songselect.build_opener')
@patch('openlp.plugins.songs.lib.songselect.BeautifulSoup')
@@ -347,8 +347,8 @@
result = importer.get_song({'link': 'link'}, callback=mocked_callback)
# THEN: The callback should have been called twice and None should be returned
- self.assertEqual(2, mocked_callback.call_count, 'The callback should have been called twice')
- self.assertIsNone(result, 'The get_song() method should have returned None')
+ assert 2 == mocked_callback.call_count, 'The callback should have been called twice'
+ assert result is None, 'The get_song() method should have returned None'
@patch('openlp.plugins.songs.lib.songselect.build_opener')
@patch('openlp.plugins.songs.lib.songselect.BeautifulSoup')
@@ -384,19 +384,18 @@
result = importer.get_song(fake_song, callback=mocked_callback)
# THEN: The callback should have been called three times and the song should be returned
- self.assertEqual(3, mocked_callback.call_count, 'The callback should have been called twice')
- self.assertIsNotNone(result, 'The get_song() method should have returned a song dictionary')
- self.assertEqual(2, mocked_lyrics_page.find.call_count, 'The find() method should have been called twice')
- self.assertEqual(2, mocked_find_all.call_count, 'The find_all() method should have been called twice')
- self.assertEqual([call('div', 'song-viewer lyrics'), call('div', 'song-viewer lyrics')],
- mocked_lyrics_page.find.call_args_list,
- 'The find() method should have been called with the right arguments')
- self.assertEqual([call('p'), call('h3')], mocked_find_all.call_args_list,
- 'The find_all() method should have been called with the right arguments')
- self.assertIn('copyright', result, 'The returned song should have a copyright')
- self.assertIn('ccli_number', result, 'The returned song should have a CCLI number')
- self.assertIn('verses', result, 'The returned song should have verses')
- self.assertEqual(3, len(result['verses']), 'Three verses should have been returned')
+ assert 3 == mocked_callback.call_count, 'The callback should have been called twice'
+ assert result is not None, 'The get_song() method should have returned a song dictionary'
+ assert 2 == mocked_lyrics_page.find.call_count, 'The find() method should have been called twice'
+ assert 2 == mocked_find_all.call_count, 'The find_all() method should have been called twice'
+ assert [call('div', 'song-viewer lyrics'), call('div', 'song-viewer lyrics')] == \
+ mocked_lyrics_page.find.call_args_list, 'The find() method should have been called with the right arguments'
+ assert [call('p'), call('h3')], mocked_find_all.call_args_list == \
+ 'The find_all() method should have been called with the right arguments'
+ assert 'copyright' in result, 'The returned song should have a copyright'
+ assert 'ccli_number' in result, 'The returned song should have a CCLI number'
+ assert 'verses' in result, 'The returned song should have verses'
+ assert 3 == len(result['verses']), 'Three verses should have been returned'
@patch('openlp.plugins.songs.lib.songselect.clean_song')
@patch('openlp.plugins.songs.lib.songselect.Topic')
@@ -427,14 +426,13 @@
result = importer.save_song(song_dict)
# THEN: The return value should be a Song class and the mocked_db_manager should have been called
- self.assertIsInstance(result, Song, 'The returned value should be a Song object')
+ assert isinstance(result, Song), 'The returned value should be a Song object'
mocked_clean_song.assert_called_with(mocked_db_manager, result)
- self.assertEqual(2, mocked_db_manager.save_object.call_count,
- 'The save_object() method should have been called twice')
+ assert 2 == mocked_db_manager.save_object.call_count, \
+ 'The save_object() method should have been called twice'
mocked_db_manager.get_object_filtered.assert_called_with(MockedAuthor, False)
- MockedAuthor.populate.assert_called_with(first_name='Public', last_name='Domain',
- display_name='Public Domain')
- self.assertEqual(1, len(result.authors_songs), 'There should only be one author')
+ MockedAuthor.populate.assert_called_with(first_name='Public', last_name='Domain', display_name='Public Domain')
+ assert 1 == len(result.authors_songs), 'There should only be one author'
@patch('openlp.plugins.songs.lib.songselect.clean_song')
@patch('openlp.plugins.songs.lib.songselect.Author')
@@ -463,13 +461,13 @@
result = importer.save_song(song_dict)
# THEN: The return value should be a Song class and the mocked_db_manager should have been called
- self.assertIsInstance(result, Song, 'The returned value should be a Song object')
+ assert isinstance(result, Song), 'The returned value should be a Song object'
mocked_clean_song.assert_called_with(mocked_db_manager, result)
- self.assertEqual(2, mocked_db_manager.save_object.call_count,
- 'The save_object() method should have been called twice')
+ assert 2 == mocked_db_manager.save_object.call_count, \
+ 'The save_object() method should have been called twice'
mocked_db_manager.get_object_filtered.assert_called_with(MockedAuthor, False)
- self.assertEqual(0, MockedAuthor.populate.call_count, 'A new author should not have been instantiated')
- self.assertEqual(1, len(result.authors_songs), 'There should only be one author')
+ assert 0 == MockedAuthor.populate.call_count, 'A new author should not have been instantiated'
+ assert 1 == len(result.authors_songs), 'There should only be one author'
@patch('openlp.plugins.songs.lib.songselect.clean_song')
@patch('openlp.plugins.songs.lib.songselect.Author')
@@ -498,14 +496,13 @@
result = importer.save_song(song_dict)
# THEN: The return value should be a Song class and the mocked_db_manager should have been called
- self.assertIsInstance(result, Song, 'The returned value should be a Song object')
+ assert isinstance(result, Song), 'The returned value should be a Song object'
mocked_clean_song.assert_called_with(mocked_db_manager, result)
- self.assertEqual(2, mocked_db_manager.save_object.call_count,
- 'The save_object() method should have been called twice')
+ assert 2 == mocked_db_manager.save_object.call_count, \
+ 'The save_object() method should have been called twice'
mocked_db_manager.get_object_filtered.assert_called_with(MockedAuthor, False)
- MockedAuthor.populate.assert_called_with(first_name='Unknown', last_name='',
- display_name='Unknown')
- self.assertEqual(1, len(result.authors_songs), 'There should only be one author')
+ MockedAuthor.populate.assert_called_with(first_name='Unknown', last_name='', display_name='Unknown')
+ assert 1 == len(result.authors_songs), 'There should only be one author'
class TestSongSelectForm(TestCase, TestMixin):
@@ -534,8 +531,8 @@
ssform = SongSelectForm(None, mocked_plugin, mocked_db_manager)
# THEN: The correct properties should have been assigned
- self.assertEqual(mocked_plugin, ssform.plugin, 'The correct plugin should have been assigned')
- self.assertEqual(mocked_db_manager, ssform.db_manager, 'The correct db_manager should have been assigned')
+ assert mocked_plugin == ssform.plugin, 'The correct plugin should have been assigned'
+ assert mocked_db_manager == ssform.db_manager, 'The correct db_manager should have been assigned'
@patch('openlp.plugins.songs.forms.songselectform.SongSelectImport')
@patch('openlp.plugins.songs.forms.songselectform.QtWidgets.QMessageBox.critical')
@@ -570,23 +567,21 @@
expected_login_spacer_calls = [call(False), call(True)]
expected_login_progress_visible_calls = [call(True), call(False)]
expected_login_progress_value_calls = [call(0), call(0)]
- self.assertEqual(expected_username_calls, mocked_username_edit.setEnabled.call_args_list,
- 'The username edit should be disabled then enabled')
- self.assertEqual(expected_password_calls, mocked_password_edit.setEnabled.call_args_list,
- 'The password edit should be disabled then enabled')
- self.assertEqual(expected_save_password_calls, mocked_save_password_checkbox.setEnabled.call_args_list,
- 'The save password checkbox should be disabled then enabled')
- self.assertEqual(expected_login_btn_calls, mocked_login_button.setEnabled.call_args_list,
- 'The login button should be disabled then enabled')
- self.assertEqual(expected_login_spacer_calls, mocked_login_spacer.setVisible.call_args_list,
- 'Thee login spacer should be make invisible, then visible')
- self.assertEqual(expected_login_progress_visible_calls,
- mocked_login_progress_bar.setVisible.call_args_list,
- 'Thee login progress bar should be make visible, then invisible')
- self.assertEqual(expected_login_progress_value_calls, mocked_login_progress_bar.setValue.call_args_list,
- 'Thee login progress bar should have the right values set')
- self.assertEqual(2, mocked_process_events.call_count,
- 'The process_events() method should be called twice')
+ assert expected_username_calls == mocked_username_edit.setEnabled.call_args_list, \
+ 'The username edit should be disabled then enabled'
+ assert expected_password_calls == mocked_password_edit.setEnabled.call_args_list, \
+ 'The password edit should be disabled then enabled'
+ assert expected_save_password_calls == mocked_save_password_checkbox.setEnabled.call_args_list, \
+ 'The save password checkbox should be disabled then enabled'
+ assert expected_login_btn_calls == mocked_login_button.setEnabled.call_args_list, \
+ 'The login button should be disabled then enabled'
+ assert expected_login_spacer_calls == mocked_login_spacer.setVisible.call_args_list, \
+ 'Thee login spacer should be make invisible, then visible'
+ assert expected_login_progress_visible_calls == mocked_login_progress_bar.setVisible.call_args_list, \
+ 'Thee login progress bar should be make visible, then invisible'
+ assert expected_login_progress_value_calls == mocked_login_progress_bar.setValue.call_args_list, \
+ 'Thee login progress bar should have the right values set'
+ assert 2 == mocked_process_events.call_count, 'The process_events() method should be called twice'
mocked_critical.assert_called_with(ssform, 'Error Logging In', 'There was a problem logging in, '
'perhaps your username or password is '
'incorrect?')
@@ -615,7 +610,7 @@
'Your song has been imported, would you like to import more songs?',
defaultButton=QtWidgets.QMessageBox.Yes)
mocked_on_back_button_clicked.assert_called_with()
- self.assertIsNone(ssform.song)
+ assert ssform.song is None
@patch('openlp.plugins.songs.forms.songselectform.QtWidgets.QMessageBox.question')
@patch('openlp.plugins.songs.forms.songselectform.translate')
@@ -641,7 +636,7 @@
'Your song has been imported, would you like to import more songs?',
defaultButton=QtWidgets.QMessageBox.Yes)
mocked_done.assert_called_with(QtWidgets.QDialog.Accepted)
- self.assertIsNone(ssform.song)
+ assert ssform.song is None
def test_on_back_button_clicked(self):
"""
@@ -769,8 +764,8 @@
# THEN: The view button, search box and search button should be enabled
mocked_song_select_importer.stop.assert_called_with()
- self.assertTrue(ssform.search_button.isEnabled())
- self.assertTrue(ssform.search_combobox.isEnabled())
+ assert ssform.search_button.isEnabled() is True
+ assert ssform.search_combobox.isEnabled() is True
@patch('openlp.plugins.songs.forms.songselectform.Settings')
@patch('openlp.plugins.songs.forms.songselectform.QtCore.QThread')
@@ -787,8 +782,8 @@
ssform.on_search_button_clicked()
# THEN: The search box and search button should be disabled
- self.assertFalse(ssform.search_button.isEnabled())
- self.assertFalse(ssform.search_combobox.isEnabled())
+ assert ssform.search_button.isEnabled() is False
+ assert ssform.search_combobox.isEnabled() is False
def test_on_search_finished(self):
"""
@@ -802,8 +797,8 @@
ssform.on_search_finished()
# THEN: The search box and search button should be enabled
- self.assertTrue(ssform.search_button.isEnabled())
- self.assertTrue(ssform.search_combobox.isEnabled())
+ assert ssform.search_button.isEnabled() is True
+ assert ssform.search_combobox.isEnabled() is True
class TestSongSelectFileImport(SongImportTestHelper):
@@ -839,8 +834,8 @@
worker = SearchWorker(importer, search_text)
# THEN: The correct values should be set
- self.assertIs(importer, worker.importer, 'The importer should be the right object')
- self.assertEqual(search_text, worker.search_text, 'The search text should be correct')
+ assert importer is worker.importer, 'The importer should be the right object'
+ assert search_text == worker.search_text, 'The search text should be correct'
def test_start(self):
"""
=== modified file 'tests/functional/openlp_plugins/songs/test_songshowplusimport.py'
--- tests/functional/openlp_plugins/songs/test_songshowplusimport.py 2017-09-30 20:16:30 +0000
+++ tests/functional/openlp_plugins/songs/test_songshowplusimport.py 2017-12-23 09:39:35 +0000
@@ -73,7 +73,7 @@
importer = SongShowPlusImport(mocked_manager, file_paths=[])
# THEN: The importer object should not be None
- self.assertIsNotNone(importer, 'Import should not be none')
+ assert importer is not None, 'Import should not be none'
def test_invalid_import_source(self):
"""
@@ -92,9 +92,9 @@
importer.import_source = source
# THEN: do_import should return none and the progress bar maximum should not be set.
- self.assertIsNone(importer.do_import(), 'do_import should return None when import_source is not a list')
- self.assertEqual(mocked_import_wizard.progress_bar.setMaximum.called, False,
- 'setMaximum on import_wizard.progress_bar should not have been called')
+ assert importer.do_import() is None, 'do_import should return None when import_source is not a list'
+ assert mocked_import_wizard.progress_bar.setMaximum.called is False, \
+ 'setMaximum on import_wizard.progress_bar should not have been called'
def test_valid_import_source(self):
"""
@@ -113,8 +113,8 @@
# THEN: do_import should return none and the progress bar setMaximum should be called with the length of
# import_source.
- self.assertIsNone(importer.do_import(), 'do_import should return None when import_source is a list '
- 'and stop_import_flag is True')
+ assert importer.do_import() is None, \
+ 'do_import should return None when import_source is a list and stop_import_flag is True'
mocked_import_wizard.progress_bar.setMaximum.assert_called_with(len(importer.import_source))
def test_to_openlp_verse_tag(self):
@@ -141,9 +141,9 @@
# THEN: The returned value should should correlate with the input arguments
for original_tag, openlp_tag in test_values:
- self.assertEqual(importer.to_openlp_verse_tag(original_tag), openlp_tag,
- 'SongShowPlusImport.to_openlp_verse_tag should return "%s" when called with "%s"' %
- (openlp_tag, original_tag))
+ assert importer.to_openlp_verse_tag(original_tag) == openlp_tag, \
+ 'SongShowPlusImport.to_openlp_verse_tag should return "%s" when called with "%s"' % \
+ (openlp_tag, original_tag)
def test_to_openlp_verse_tag_verse_order(self):
"""
@@ -170,6 +170,6 @@
# THEN: The returned value should should correlate with the input arguments
for original_tag, openlp_tag in test_values:
- self.assertEqual(importer.to_openlp_verse_tag(original_tag, ignore_unique=True), openlp_tag,
- 'SongShowPlusImport.to_openlp_verse_tag should return "%s" when called with "%s"' %
- (openlp_tag, original_tag))
+ assert importer.to_openlp_verse_tag(original_tag, ignore_unique=True) == openlp_tag, \
+ 'SongShowPlusImport.to_openlp_verse_tag should return "%s" when called with "%s"' % \
+ (openlp_tag, original_tag)
=== modified file 'tests/functional/openlp_plugins/songs/test_worshipcenterproimport.py'
--- tests/functional/openlp_plugins/songs/test_worshipcenterproimport.py 2017-12-22 10:45:39 +0000
+++ tests/functional/openlp_plugins/songs/test_worshipcenterproimport.py 2017-12-23 09:39:35 +0000
@@ -156,7 +156,7 @@
importer = WorshipCenterProImport(mocked_manager, file_paths=[])
# THEN: The importer object should not be None
- self.assertIsNotNone(importer, 'Import should not be none')
+ assert importer is not None, 'Import should not be none'
def test_pyodbc_exception(self):
"""
@@ -181,7 +181,7 @@
return_value = importer.do_import()
# THEN: do_import should return None, and pyodbc, translate & log_error are called with known calls
- self.assertIsNone(return_value, 'do_import should return None when pyodbc raises an exception.')
+ assert return_value is None, 'do_import should return None when pyodbc raises an exception.'
mocked_pyodbc_connect.assert_called_with('DRIVER={Microsoft Access Driver (*.mdb)};DBQ=import_source')
mocked_translate.assert_called_with('SongsPlugin.WorshipCenterProImport',
'Unable to connect the WorshipCenter Pro database.')
@@ -220,7 +220,7 @@
# THEN: do_import should return None, and pyodbc, import_wizard, importer.title and add_verse are called
# with known calls
- self.assertIsNone(return_value, 'do_import should return None when pyodbc raises an exception.')
+ assert return_value is None, 'do_import should return None when pyodbc raises an exception.'
mocked_pyodbc.connect.assert_called_with('DRIVER={Microsoft Access Driver (*.mdb)};DBQ=import_source')
mocked_pyodbc.connect().cursor.assert_any_call()
mocked_pyodbc.connect().cursor().execute.assert_called_with('SELECT ID, Field, Value FROM __SONGDATA')
@@ -229,8 +229,7 @@
add_verse_call_count = 0
for song_data in SONG_TEST_DATA:
title_value = song_data['title']
- self.assertIn(title_value, importer._title_assignment_list,
- 'title should have been set to %s' % title_value)
+ assert title_value in importer._title_assignment_list, 'title should have been set to %s' % title_value
verse_calls = song_data['verses']
add_verse_call_count += len(verse_calls)
for call in verse_calls:
@@ -241,5 +240,4 @@
mocked_add_comment.assert_any_call(song_data['comments'])
if 'copyright' in song_data:
mocked_add_copyright.assert_any_call(song_data['copyright'])
- self.assertEqual(mocked_add_verse.call_count, add_verse_call_count,
- 'Incorrect number of calls made to add_verse')
+ assert mocked_add_verse.call_count == add_verse_call_count, 'Incorrect number of calls made to add_verse'
=== modified file 'tests/functional/openlp_plugins/songs/test_zionworximport.py'
--- tests/functional/openlp_plugins/songs/test_zionworximport.py 2017-10-10 02:29:56 +0000
+++ tests/functional/openlp_plugins/songs/test_zionworximport.py 2017-12-23 09:39:35 +0000
@@ -59,7 +59,7 @@
importer = ZionWorxImport(mocked_manager, file_paths=[])
# THEN: The importer should be an instance of SongImport
- self.assertIsInstance(importer, SongImport)
+ assert isinstance(importer, SongImport)
class TestZionWorxFileImport(SongImportTestHelper):
=== modified file 'tests/functional/openlp_plugins/songusage/test_songusage.py'
--- tests/functional/openlp_plugins/songusage/test_songusage.py 2017-10-10 07:08:44 +0000
+++ tests/functional/openlp_plugins/songusage/test_songusage.py 2017-12-23 09:39:35 +0000
@@ -43,10 +43,10 @@
# GIVEN: The SongUsagePlugin
# WHEN: Retrieving the about text
# THEN: about() should return a string object
- self.assertIsInstance(SongUsagePlugin.about(), str)
+ assert isinstance(SongUsagePlugin.about(), str)
# THEN: about() should return a non-empty string
- self.assertNotEquals(len(SongUsagePlugin.about()), 0)
- self.assertNotEquals(len(SongUsagePlugin.about()), 0)
+ assert len(SongUsagePlugin.about()) is not 0
+ assert len(SongUsagePlugin.about()) is not 0
@patch('openlp.plugins.songusage.songusageplugin.Manager')
def test_song_usage_init(self, MockedManager):
@@ -62,8 +62,8 @@
# THEN: It should be initialised correctly
MockedManager.assert_called_with('songusage', init_schema, upgrade_mod=upgrade)
- self.assertEqual(mocked_manager, song_usage.manager)
- self.assertFalse(song_usage.song_usage_active)
+ assert mocked_manager == song_usage.manager
+ assert song_usage.song_usage_active is False
@patch('openlp.plugins.songusage.songusageplugin.Manager')
def test_check_pre_conditions(self, MockedManager):
@@ -80,7 +80,7 @@
ret = song_usage.check_pre_conditions()
# THEN: It should return True
- self.assertTrue(ret)
+ assert ret is True
@patch('openlp.plugins.songusage.songusageplugin.Manager')
def test_toggle_song_usage_state(self, MockedManager):
@@ -96,4 +96,4 @@
song_usage.toggle_song_usage_state()
# THEN: song_usage_state should have been toogled
- self.assertFalse(song_usage.song_usage_active)
+ assert song_usage.song_usage_active is False
=== modified file 'tests/helpers/songfileimport.py'
--- tests/helpers/songfileimport.py 2017-10-10 02:29:56 +0000
+++ tests/helpers/songfileimport.py 2017-12-23 09:39:35 +0000
@@ -108,7 +108,7 @@
verse_order_list = self._get_data(result_data, 'verse_order_list')
# THEN: do_import should return none, the song data should be as expected, and finish should have been called.
- self.assertIsNone(importer.do_import(), 'do_import should return None when it has completed')
+ assert importer.do_import() is None, 'do_import should return None when it has completed'
# Debug information - will be displayed when the test fails
log.debug("Title imported: %s" % importer.title)
@@ -122,7 +122,7 @@
log.debug("Song copyright imported: %s" % importer.song_number)
log.debug("Topics imported: %s" % importer.topics)
- self.assertEqual(importer.title, title, 'title for %s should be "%s"' % (source_file_name, title))
+ assert importer.title == title, 'title for %s should be "%s"' % (source_file_name, title)
for author in author_calls:
if isinstance(author, str):
self.mocked_add_author.assert_any_call(author)
@@ -131,27 +131,27 @@
if song_copyright:
self.mocked_add_copyright.assert_called_with(song_copyright)
if ccli_number:
- self.assertEqual(importer.ccli_number, ccli_number,
- 'ccli_number for %s should be %s' % (source_file_name, ccli_number))
+ assert importer.ccli_number == ccli_number, \
+ 'ccli_number for %s should be %s' % (source_file_name, ccli_number)
expected_calls = []
for verse_text, verse_tag in add_verse_calls:
self.mocked_add_verse.assert_any_call(verse_text, verse_tag)
expected_calls.append(call(verse_text, verse_tag))
self.mocked_add_verse.assert_has_calls(expected_calls, any_order=False)
if topics:
- self.assertEqual(importer.topics, topics, 'topics for %s should be %s' % (source_file_name, topics))
+ assert importer.topics == topics, 'topics for %s should be %s' % (source_file_name, topics)
if comments:
- self.assertEqual(importer.comments, comments,
- 'comments for %s should be "%s"' % (source_file_name, comments))
+ assert importer.comments == comments, \
+ 'comments for %s should be "%s"' % (source_file_name, comments)
if song_book_name:
- self.assertEqual(importer.song_book_name, song_book_name,
- 'song_book_name for %s should be "%s"' % (source_file_name, song_book_name))
+ assert importer.song_book_name == song_book_name, \
+ 'song_book_name for %s should be "%s"' % (source_file_name, song_book_name)
if song_number:
- self.assertEqual(importer.song_number, song_number,
- 'song_number for %s should be %s' % (source_file_name, song_number))
+ assert importer.song_number == song_number, \
+ 'song_number for %s should be %s' % (source_file_name, song_number)
if verse_order_list:
- self.assertEqual(importer.verse_order_list, verse_order_list,
- 'verse_order_list for %s should be %s' % (source_file_name, verse_order_list))
+ assert importer.verse_order_list == verse_order_list, \
+ 'verse_order_list for %s should be %s' % (source_file_name, verse_order_list)
self.mocked_finish.assert_called_with()
def _get_data(self, data, key):
=== modified file 'tests/interfaces/openlp_core/lib/test_pluginmanager.py'
--- tests/interfaces/openlp_core/lib/test_pluginmanager.py 2017-11-18 11:23:15 +0000
+++ tests/interfaces/openlp_core/lib/test_pluginmanager.py 2017-12-23 09:39:35 +0000
@@ -86,11 +86,11 @@
# THEN: We should find the "Songs", "Bibles", etc in the plugins list
plugin_names = [plugin.name for plugin in plugin_manager.plugins]
- self.assertIn('songs', plugin_names, 'There should be a "songs" plugin')
- self.assertIn('bibles', plugin_names, 'There should be a "bibles" plugin')
- self.assertIn('presentations', plugin_names, 'There should be a "presentations" plugin')
- self.assertIn('images', plugin_names, 'There should be a "images" plugin')
- self.assertIn('media', plugin_names, 'There should be a "media" plugin')
- self.assertIn('custom', plugin_names, 'There should be a "custom" plugin')
- self.assertIn('songusage', plugin_names, 'There should be a "songusage" plugin')
- self.assertIn('alerts', plugin_names, 'There should be a "alerts" plugin')
+ assert 'songs' in plugin_names, 'There should be a "songs" plugin'
+ assert 'bibles' in plugin_names, 'There should be a "bibles" plugin'
+ assert 'presentations' in plugin_names, 'There should be a "presentations" plugin'
+ assert 'images' in plugin_names, 'There should be a "images" plugin'
+ assert 'media' in plugin_names, 'There should be a "media" plugin'
+ assert 'custom' in plugin_names, 'There should be a "custom" plugin'
+ assert 'songusage'in plugin_names, 'There should be a "songusage" plugin'
+ assert 'alerts' in plugin_names, 'There should be a "alerts" plugin'
=== modified file 'tests/interfaces/openlp_core/ui/media/vendor/test_mediainfoWrapper.py'
--- tests/interfaces/openlp_core/ui/media/vendor/test_mediainfoWrapper.py 2017-11-15 07:03:35 +0000
+++ tests/interfaces/openlp_core/ui/media/vendor/test_mediainfoWrapper.py 2017-12-23 09:39:35 +0000
@@ -46,5 +46,4 @@
results = MediaInfoWrapper.parse(full_path)
# THEN you can determine the run time
- self.assertEqual(results.tracks[0].duration, test_data[1], 'The correct duration is returned for ' +
- test_data[0])
+ assert results.tracks[0].duration == test_data[1], 'The correct duration is returned for ' + test_data[0]
=== modified file 'tests/interfaces/openlp_core/ui/test_filerenamedialog.py'
--- tests/interfaces/openlp_core/ui/test_filerenamedialog.py 2017-10-07 07:05:07 +0000
+++ tests/interfaces/openlp_core/ui/test_filerenamedialog.py 2017-12-23 09:39:35 +0000
@@ -63,19 +63,19 @@
self.form.exec()
# THEN: the window title is set correctly
- self.assertEqual(self.form.windowTitle(), 'File Rename', 'The window title should be "File Rename"')
+ assert self.form.windowTitle() == 'File Rename', 'The window title should be "File Rename"'
# WHEN: The form is executed with False arg
self.form.exec(False)
# THEN: the window title is set correctly
- self.assertEqual(self.form.windowTitle(), 'File Rename', 'The window title should be "File Rename"')
+ assert self.form.windowTitle() == 'File Rename', 'The window title should be "File Rename"'
# WHEN: The form is executed with True arg
self.form.exec(True)
# THEN: the window title is set correctly
- self.assertEqual(self.form.windowTitle(), 'File Copy', 'The window title should be "File Copy"')
+ assert self.form.windowTitle() == 'File Copy', 'The window title should be "File Copy"'
def test_line_edit_focus(self):
"""
@@ -104,4 +104,4 @@
# THEN: The text in the QLineEdit should be the same as the input string with the invalid characters filtered
# out.
- self.assertEqual(self.form.file_name_edit.text(), 'Invalid File Name')
+ assert self.form.file_name_edit.text() == 'Invalid File Name'
=== modified file 'tests/interfaces/openlp_core/ui/test_projectormanager.py'
--- tests/interfaces/openlp_core/ui/test_projectormanager.py 2017-11-16 23:53:53 +0000
+++ tests/interfaces/openlp_core/ui/test_projectormanager.py 2017-12-23 09:39:35 +0000
@@ -70,8 +70,8 @@
# WHEN: we call bootstrap_initialise
self.projector_manager.bootstrap_initialise()
# THEN: ProjectorDB is setup
- self.assertEqual(type(self.projector_manager.projectordb), ProjectorDB,
- 'Initialization should have created a ProjectorDB() instance')
+ assert type(self.projector_manager.projectordb) == ProjectorDB, \
+ 'Initialization should have created a ProjectorDB() instance'
def test_bootstrap_post_set_up(self):
"""
@@ -85,10 +85,9 @@
self.projector_manager.bootstrap_post_set_up()
# THEN: verify calls to retrieve saved projectors and edit page initialized
- self.assertEqual(1, self.projector_manager._load_projectors.call_count,
- 'Initialization should have called load_projectors()')
- self.assertEqual(type(self.projector_manager.projector_form), ProjectorEditForm,
- 'Initialization should have created a Projector Edit Form')
- self.assertIs(self.projector_manager.projectordb,
- self.projector_manager.projector_form.projectordb,
- 'ProjectorEditForm should be using same ProjectorDB() instance as ProjectorManager')
+ assert 1 == self.projector_manager._load_projectors.call_count, \
+ 'Initialization should have called load_projectors()'
+ assert type(self.projector_manager.projector_form) == ProjectorEditForm, \
+ 'Initialization should have created a Projector Edit Form'
+ assert self.projector_manager.projectordb is self.projector_manager.projector_form.projectordb, \
+ 'ProjectorEditForm should be using same ProjectorDB() instance as ProjectorManager'
=== modified file 'tests/interfaces/openlp_core/ui/test_projectorsourceform.py'
--- tests/interfaces/openlp_core/ui/test_projectorsourceform.py 2017-11-15 00:19:49 +0000
+++ tests/interfaces/openlp_core/ui/test_projectorsourceform.py 2017-12-23 09:39:35 +0000
@@ -111,8 +111,7 @@
check = source_group(codes, PJLINK_DEFAULT_CODES)
# THEN: return dictionary should match test dictionary
- self.assertEquals(check, build_source_dict(),
- "Source group dictionary should match test dictionary")
+ assert check == build_source_dict(), "Source group dictionary should match test dictionary"
@patch.object(QDialog, 'exec')
def test_source_select_edit_button(self, mocked_qdialog):
@@ -130,9 +129,8 @@
projector = select_form.projector
# THEN: Verify all 4 buttons are available
- self.assertEquals(len(select_form.button_box.buttons()), 4,
- 'SourceSelect dialog box should have "OK", "Cancel" '
- '"Rest", and "Revert" buttons available')
+ assert len(select_form.button_box.buttons()) == 4, \
+ 'SourceSelect dialog box should have "OK", "Cancel", "Rest", and "Revert" buttons available'
@patch.object(QDialog, 'exec')
def test_source_select_noedit_button(self, mocked_qdialog):
@@ -150,6 +148,5 @@
projector = select_form.projector
# THEN: Verify only 2 buttons are available
- self.assertEquals(len(select_form.button_box.buttons()), 2,
- 'SourceSelect dialog box should only have "OK" '
- 'and "Cancel" buttons available')
+ assert len(select_form.button_box.buttons()) == 2, \
+ 'SourceSelect dialog box should only have "OK" and "Cancel" buttons available'
=== modified file 'tests/interfaces/openlp_core/ui/test_servicemanager.py'
--- tests/interfaces/openlp_core/ui/test_servicemanager.py 2017-10-23 22:09:57 +0000
+++ tests/interfaces/openlp_core/ui/test_servicemanager.py 2017-12-23 09:39:35 +0000
@@ -79,8 +79,8 @@
self.service_manager.setup_ui(self.service_manager)
# THEN the count of items should be zero
- self.assertEqual(self.service_manager.service_manager_list.topLevelItemCount(), 0,
- 'The service manager list should be empty ')
+ assert self.service_manager.service_manager_list.topLevelItemCount() == 0, \
+ 'The service manager list should be empty '
@patch('openlp.core.ui.servicemanager.QtWidgets.QTreeWidget.itemAt')
@patch('openlp.core.ui.servicemanager.QtWidgets.QWidget.mapToGlobal')
@@ -447,8 +447,8 @@
# THEN selection should be expanded
selected_index = self.service_manager.service_manager_list.currentIndex()
above_selected_index = self.service_manager.service_manager_list.indexAbove(selected_index)
- self.assertTrue(self.service_manager.service_manager_list.isExpanded(above_selected_index),
- 'Item should have been expanded')
+ assert self.service_manager.service_manager_list.isExpanded(above_selected_index) is True, \
+ 'Item should have been expanded'
self.service_manager.expanded.assert_called_once_with(song_item)
def test_on_collapse_selection_with_parent_selected(self):
@@ -468,10 +468,10 @@
# THEN selection should be expanded
selected_index = self.service_manager.service_manager_list.currentIndex()
- self.assertFalse(self.service_manager.service_manager_list.isExpanded(selected_index),
- 'Item should have been collapsed')
- self.assertTrue(self.service_manager.service_manager_list.currentItem() == song_item,
- 'Top item should have been selected')
+ assert self.service_manager.service_manager_list.isExpanded(selected_index) is False, \
+ 'Item should have been collapsed'
+ assert self.service_manager.service_manager_list.currentItem() == song_item, \
+ 'Top item should have been selected'
self.service_manager.collapsed.assert_called_once_with(song_item)
def test_on_collapse_selection_with_child_selected(self):
@@ -491,8 +491,8 @@
# THEN selection should be expanded
selected_index = self.service_manager.service_manager_list.currentIndex()
- self.assertFalse(self.service_manager.service_manager_list.isExpanded(selected_index),
- 'Item should have been collapsed')
- self.assertTrue(self.service_manager.service_manager_list.currentItem() == song_item,
- 'Top item should have been selected')
+ assert self.service_manager.service_manager_list.isExpanded(selected_index) is False, \
+ 'Item should have been collapsed'
+ assert self.service_manager.service_manager_list.currentItem() == song_item, \
+ 'Top item should have been selected'
self.service_manager.collapsed.assert_called_once_with(song_item)
=== modified file 'tests/interfaces/openlp_core/ui/test_servicenotedialog.py'
--- tests/interfaces/openlp_core/ui/test_servicenotedialog.py 2017-10-07 07:05:07 +0000
+++ tests/interfaces/openlp_core/ui/test_servicenotedialog.py 2017-12-23 09:39:35 +0000
@@ -66,7 +66,7 @@
QtTest.QTest.mouseClick(ok_widget, QtCore.Qt.LeftButton)
# THEN the following input text is returned
- self.assertEqual(self.form.text_edit.toPlainText(), '', 'The returned text should be empty')
+ assert self.form.text_edit.toPlainText() == '', 'The returned text should be empty'
# WHEN displaying the UI, having set the text and pressing enter
text = 'OpenLP is the best worship software'
@@ -77,7 +77,7 @@
QtTest.QTest.mouseClick(ok_widget, QtCore.Qt.LeftButton)
# THEN the following text is returned
- self.assertEqual(self.form.text_edit.toPlainText(), text, 'The text originally entered should still be there')
+ assert self.form.text_edit.toPlainText() == text, 'The text originally entered should still be there'
# WHEN displaying the UI, having set the text and pressing enter
self.form.text_edit.setPlainText('')
@@ -88,4 +88,4 @@
QtTest.QTest.mouseClick(ok_widget, QtCore.Qt.LeftButton)
# THEN the following text is returned
- self.assertEqual(self.form.text_edit.toPlainText(), text, 'The new text should be returned')
+ assert self.form.text_edit.toPlainText() == text, 'The new text should be returned'
=== modified file 'tests/interfaces/openlp_core/ui/test_shortcutlistform.py'
--- tests/interfaces/openlp_core/ui/test_shortcutlistform.py 2017-10-07 07:05:07 +0000
+++ tests/interfaces/openlp_core/ui/test_shortcutlistform.py 2017-12-23 09:39:35 +0000
@@ -67,9 +67,9 @@
self.form._adjust_button(button, checked, enabled, text)
# THEN: The button should be changed.
- self.assertEqual(button.text(), text, 'The text should match.')
+ assert button.text() == text, 'The text should match.'
mocked_check_method.assert_called_once_with(True)
- self.assertEqual(button.isEnabled(), enabled, 'The button should be disabled.')
+ assert button.isEnabled() == enabled, 'The button should be disabled.'
def test_space_key_press_event(self):
"""
@@ -85,7 +85,7 @@
# THEN: The key should be released
mocked_key_release_event.assert_called_with(mocked_event)
- self.assertEqual(0, mocked_event.accept.call_count)
+ assert 0 == mocked_event.accept.call_count
def test_primary_push_button_checked_key_press_event(self):
"""
@@ -102,7 +102,7 @@
# THEN: The key should be released
mocked_key_release_event.assert_called_with(mocked_event)
- self.assertEqual(0, mocked_event.accept.call_count)
+ assert 0 == mocked_event.accept.call_count
def test_alternate_push_button_checked_key_press_event(self):
"""
@@ -119,7 +119,7 @@
# THEN: The key should be released
mocked_key_release_event.assert_called_with(mocked_event)
- self.assertEqual(0, mocked_event.accept.call_count)
+ assert 0 == mocked_event.accept.call_count
def test_escape_key_press_event(self):
"""
@@ -148,7 +148,7 @@
self.form.on_default_radio_button_clicked(False)
# THEN: The method should exit early (i.e. the rest of the methods are not called)
- self.assertEqual(0, mocked_current_item_action.call_count)
+ assert 0 == mocked_current_item_action.call_count
def test_on_default_radio_button_clicked_no_action(self):
"""
@@ -164,7 +164,7 @@
# THEN: The method should exit early (i.e. the rest of the methods are not called)
mocked_current_item_action.assert_called_with()
- self.assertEqual(0, mocked_action_shortcuts.call_count)
+ assert 0 == mocked_action_shortcuts.call_count
def test_on_default_radio_button_clicked(self):
"""
@@ -202,7 +202,7 @@
self.form.on_custom_radio_button_clicked(False)
# THEN: The method should exit early (i.e. the rest of the methods are not called)
- self.assertEqual(0, mocked_current_item_action.call_count)
+ assert 0 == mocked_current_item_action.call_count
def test_on_custom_radio_button_clicked(self):
"""
=== modified file 'tests/interfaces/openlp_core/ui/test_starttimedialog.py'
--- tests/interfaces/openlp_core/ui/test_starttimedialog.py 2017-10-07 07:05:07 +0000
+++ tests/interfaces/openlp_core/ui/test_starttimedialog.py 2017-12-23 09:39:35 +0000
@@ -56,28 +56,24 @@
"""
Test StartTimeDialog are defaults correct
"""
- self.assertEqual(self.form.hour_spin_box.minimum(), 0, 'The minimum hour should stay the same as the dialog')
- self.assertEqual(self.form.hour_spin_box.maximum(), 4, 'The maximum hour should stay the same as the dialog')
- self.assertEqual(self.form.minute_spin_box.minimum(), 0,
- 'The minimum minute should stay the same as the dialog')
- self.assertEqual(self.form.minute_spin_box.maximum(), 59,
- 'The maximum minute should stay the same as the dialog')
- self.assertEqual(self.form.second_spin_box.minimum(), 0,
- 'The minimum second should stay the same as the dialog')
- self.assertEqual(self.form.second_spin_box.maximum(), 59,
- 'The maximum second should stay the same as the dialog')
- self.assertEqual(self.form.hour_finish_spin_box.minimum(), 0,
- 'The minimum finish hour should stay the same as the dialog')
- self.assertEqual(self.form.hour_finish_spin_box.maximum(), 4,
- 'The maximum finish hour should stay the same as the dialog')
- self.assertEqual(self.form.minute_finish_spin_box.minimum(), 0,
- 'The minimum finish minute should stay the same as the dialog')
- self.assertEqual(self.form.minute_finish_spin_box.maximum(), 59,
- 'The maximum finish minute should stay the same as the dialog')
- self.assertEqual(self.form.second_finish_spin_box.minimum(), 0,
- 'The minimum finish second should stay the same as the dialog')
- self.assertEqual(self.form.second_finish_spin_box.maximum(), 59,
- 'The maximum finish second should stay the same as the dialog')
+ assert self.form.hour_spin_box.minimum() == 0, 'The minimum hour should stay the same as the dialog'
+ assert self.form.hour_spin_box.maximum() == 4, 'The maximum hour should stay the same as the dialog'
+ assert self.form.minute_spin_box.minimum() == 0, 'The minimum minute should stay the same as the dialog'
+ assert self.form.minute_spin_box.maximum() == 59, 'The maximum minute should stay the same as the dialog'
+ assert self.form.second_spin_box.minimum() == 0, 'The minimum second should stay the same as the dialog'
+ assert self.form.second_spin_box.maximum() == 59, 'The maximum second should stay the same as the dialog'
+ assert self.form.hour_finish_spin_box.minimum() == 0, \
+ 'The minimum finish hour should stay the same as the dialog'
+ assert self.form.hour_finish_spin_box.maximum() == 4, \
+ 'The maximum finish hour should stay the same as the dialog'
+ assert self.form.minute_finish_spin_box.minimum() == 0, \
+ 'The minimum finish minute should stay the same as the dialog'
+ assert self.form.minute_finish_spin_box.maximum() == 59, \
+ 'The maximum finish minute should stay the same as the dialog'
+ assert self.form.second_finish_spin_box.minimum() == 0, \
+ 'The minimum finish second should stay the same as the dialog'
+ assert self.form.second_finish_spin_box.maximum() == 59, \
+ 'The maximum finish second should stay the same as the dialog'
def test_time_display(self):
"""
@@ -97,10 +93,10 @@
QtTest.QTest.mouseClick(ok_widget, QtCore.Qt.LeftButton)
# THEN the following input values are returned
- self.assertEqual(self.form.hour_spin_box.value(), 0)
- self.assertEqual(self.form.minute_spin_box.value(), 1)
- self.assertEqual(self.form.second_spin_box.value(), 1)
- self.assertEqual(self.form.item['service_item'].start_time, 61, 'The start time should stay the same')
+ assert self.form.hour_spin_box.value() == 0
+ assert self.form.minute_spin_box.value() == 1
+ assert self.form.second_spin_box.value() == 1
+ assert self.form.item['service_item'].start_time == 61, 'The start time should stay the same'
# WHEN displaying the UI, changing the time to 2min 3secs and pressing enter
self.form.item = {'service_item': mocked_serviceitem}
@@ -112,7 +108,7 @@
QtTest.QTest.mouseClick(ok_widget, QtCore.Qt.LeftButton)
# THEN the following values are returned
- self.assertEqual(self.form.hour_spin_box.value(), 0)
- self.assertEqual(self.form.minute_spin_box.value(), 2)
- self.assertEqual(self.form.second_spin_box.value(), 3)
- self.assertEqual(self.form.item['service_item'].start_time, 123, 'The start time should have changed')
+ assert self.form.hour_spin_box.value() == 0
+ assert self.form.minute_spin_box.value() == 2
+ assert self.form.second_spin_box.value() == 3
+ assert self.form.item['service_item'].start_time == 123, 'The start time should have changed'
=== modified file 'tests/interfaces/openlp_core/ui/test_thememanager.py'
--- tests/interfaces/openlp_core/ui/test_thememanager.py 2017-11-03 22:52:24 +0000
+++ tests/interfaces/openlp_core/ui/test_thememanager.py 2017-12-23 09:39:35 +0000
@@ -121,4 +121,4 @@
self.theme_manager.bootstrap_post_set_up()
# THEN:
- self.assertEqual(1, self.theme_manager.load_themes.call_count, "load_themes should have been called once")
+ assert 1 == self.theme_manager.load_themes.call_count, "load_themes should have been called once"
=== modified file 'tests/interfaces/openlp_core/widgets/test_edits.py'
--- tests/interfaces/openlp_core/widgets/test_edits.py 2017-10-23 22:09:57 +0000
+++ tests/interfaces/openlp_core/widgets/test_edits.py 2017-12-23 09:39:35 +0000
@@ -86,8 +86,8 @@
# THEN: The first search type should be the first one in the list. The selected type should be saved in the
# settings
- self.assertEqual(self.search_edit.current_search_type(), SearchTypes.First,
- "The first search type should be selected.")
+ assert self.search_edit.current_search_type() == SearchTypes.First, \
+ "The first search type should be selected."
self.mocked_settings().setValue.assert_called_once_with('settings_section/last used search type', 0)
def test_set_current_search_type(self):
@@ -99,11 +99,11 @@
result = self.search_edit.set_current_search_type(SearchTypes.Second)
# THEN:
- self.assertTrue(result, "The call should return success (True).")
- self.assertEqual(self.search_edit.current_search_type(), SearchTypes.Second,
- "The search type should be SearchTypes.Second")
- self.assertEqual(self.search_edit.placeholderText(), SECOND_PLACEHOLDER_TEXT,
- "The correct placeholder text should be 'Second Placeholder Text'.")
+ assert result is True, "The call should return success (True)."
+ assert self.search_edit.current_search_type() == SearchTypes.Second, \
+ "The search type should be SearchTypes.Second"
+ assert self.search_edit.placeholderText() == SECOND_PLACEHOLDER_TEXT, \
+ "The correct placeholder text should be 'Second Placeholder Text'."
self.mocked_settings().setValue.assert_has_calls(
[call('settings_section/last used search type', 0), call('settings_section/last used search type', 1)])
@@ -166,4 +166,4 @@
self.combo.addItem('test2')
# THEN: The list of items should contain both strings.
- self.assertEqual(self.combo.getItems(), ['test1', 'test2'])
+ assert self.combo.getItems() == ['test1', 'test2']
=== modified file 'tests/interfaces/openlp_core/widgets/test_views.py'
--- tests/interfaces/openlp_core/widgets/test_views.py 2017-10-23 22:09:57 +0000
+++ tests/interfaces/openlp_core/widgets/test_views.py 2017-12-23 09:39:35 +0000
@@ -64,7 +64,7 @@
# GIVEN: A new ListPreviewWidget instance.
# WHEN: No SlideItem has been added yet.
# THEN: The count of items should be zero.
- self.assertEqual(self.preview_widget.slide_count(), 0, 'The slide list should be empty.')
+ assert self.preview_widget.slide_count() == 0, 'The slide list should be empty.'
def test_initial_slide_number(self):
"""
@@ -73,7 +73,7 @@
# GIVEN: A new ListPreviewWidget instance.
# WHEN: No SlideItem has been added yet.
# THEN: The number of the current item should be -1.
- self.assertEqual(self.preview_widget.current_slide_number(), -1, 'The slide number should be -1.')
+ assert self.preview_widget.current_slide_number() == -1, 'The slide number should be -1.'
def test_replace_service_item(self):
"""
@@ -87,8 +87,8 @@
# WHEN: Added to the preview widget.
self.preview_widget.replace_service_item(service_item, 1, 1)
# THEN: The slide count and number should fit.
- self.assertEqual(self.preview_widget.slide_count(), 2, 'The slide count should be 2.')
- self.assertEqual(self.preview_widget.current_slide_number(), 1, 'The current slide number should be 1.')
+ assert self.preview_widget.slide_count() == 2, 'The slide count should be 2.'
+ assert self.preview_widget.current_slide_number() == 1, 'The current slide number should be 1.'
def test_change_slide(self):
"""
@@ -103,4 +103,4 @@
self.preview_widget.replace_service_item(service_item, 1, 0)
self.preview_widget.change_slide(1)
# THEN: The current_slide_number should reflect the change.
- self.assertEqual(self.preview_widget.current_slide_number(), 1, 'The current slide number should be 1.')
+ assert self.preview_widget.current_slide_number() == 1, 'The current slide number should be 1.'
=== modified file 'tests/interfaces/openlp_plugins/bibles/forms/test_bibleimportform.py'
--- tests/interfaces/openlp_plugins/bibles/forms/test_bibleimportform.py 2017-10-07 07:05:07 +0000
+++ tests/interfaces/openlp_plugins/bibles/forms/test_bibleimportform.py 2017-12-23 09:39:35 +0000
@@ -78,7 +78,7 @@
self.form.on_web_update_button_clicked()
# THEN: The webbible list should still be empty
- self.assertEqual(self.form.web_bible_list, {}, 'The webbible list should be empty')
+ assert self.form.web_bible_list == {}, 'The webbible list should be empty'
def test_custom_init(self):
"""
=== modified file 'tests/interfaces/openlp_plugins/bibles/test_lib_http.py'
--- tests/interfaces/openlp_plugins/bibles/test_lib_http.py 2017-10-07 07:05:07 +0000
+++ tests/interfaces/openlp_plugins/bibles/test_lib_http.py 2017-12-23 09:39:35 +0000
@@ -53,8 +53,8 @@
books = handler.get_books_from_http('NIV')
# THEN: We should get back a valid service item
- self.assertEqual(len(books), 66, 'The bible should not have had any books added or removed')
- self.assertEqual(books[0], 'Genesis', 'The first bible book should be Genesis')
+ assert len(books) == 66, 'The bible should not have had any books added or removed'
+ assert books[0] == 'Genesis', 'The first bible book should be Genesis'
def test_bible_gateway_extract_books_support_redirect(self):
"""
@@ -67,7 +67,7 @@
books = handler.get_books_from_http('DN1933')
# THEN: We should get back a valid service item
- self.assertEqual(len(books), 66, 'This bible should have 66 books')
+ assert len(books) == 66, 'This bible should have 66 books'
def test_bible_gateway_extract_verse(self):
"""
@@ -80,8 +80,7 @@
results = handler.get_bible_chapter('NIV', 'John', 3)
# THEN: We should get back a valid service item
- self.assertEqual(len(results.verse_list), 36,
- 'The book of John should not have had any verses added or removed')
+ assert len(results.verse_list) == 36, 'The book of John should not have had any verses added or removed'
def test_bible_gateway_extract_verse_nkjv(self):
"""
@@ -94,8 +93,7 @@
results = handler.get_bible_chapter('NKJV', 'John', 3)
# THEN: We should get back a valid service item
- self.assertEqual(len(results.verse_list), 36,
- 'The book of John should not have had any verses added or removed')
+ assert len(results.verse_list) == 36, 'The book of John should not have had any verses added or removed'
def test_crosswalk_extract_books(self):
"""
@@ -108,7 +106,7 @@
books = handler.get_books_from_http('niv')
# THEN: We should get back a valid service item
- self.assertEqual(len(books), 66, 'The bible should not have had any books added or removed')
+ assert len(books) == 66, 'The bible should not have had any books added or removed'
def test_crosswalk_extract_verse(self):
"""
@@ -121,8 +119,7 @@
results = handler.get_bible_chapter('niv', 'john', 3)
# THEN: We should get back a valid service item
- self.assertEqual(len(results.verse_list), 36,
- 'The book of John should not have had any verses added or removed')
+ assert len(results.verse_list) == 36, 'The book of John should not have had any verses added or removed'
def test_bibleserver_get_bibles(self):
"""
@@ -135,9 +132,9 @@
bibles = handler.get_bibles_from_http()
# THEN: The list should not be None, and some known bibles should be there
- self.assertIsNotNone(bibles)
- self.assertIn(('New Int. Readers Version', 'NIRV', 'en'), bibles)
- self.assertIn(('Священное Писание, Восточный перевод', 'CARS', 'ru'), bibles)
+ assert bibles is not None
+ assert ('New Int. Readers Version', 'NIRV', 'en') in bibles
+ assert ('Священное Писание, Восточный перевод', 'CARS', 'ru') in bibles
def test_biblegateway_get_bibles(self):
"""
@@ -150,8 +147,8 @@
bibles = handler.get_bibles_from_http()
# THEN: The list should not be None, and some known bibles should be there
- self.assertIsNotNone(bibles)
- self.assertIn(('Holman Christian Standard Bible (HCSB)', 'HCSB', 'en'), bibles)
+ assert bibles is not None
+ assert ('Holman Christian Standard Bible (HCSB)', 'HCSB', 'en') in bibles
def test_crosswalk_get_bibles(self):
"""
@@ -164,8 +161,8 @@
bibles = handler.get_bibles_from_http()
# THEN: The list should not be None, and some known bibles should be there
- self.assertIsNotNone(bibles)
- self.assertIn(('Giovanni Diodati 1649 (Italian)', 'gdb', 'it'), bibles)
+ assert bibles is not None
+ assert ('Giovanni Diodati 1649 (Italian)', 'gdb', 'it') in bibles
def test_crosswalk_get_verse_text(self):
"""
@@ -178,7 +175,6 @@
niv_genesis_chapter_one = handler.get_bible_chapter('niv', 'Genesis', 1)
# THEN: The verse list should contain the verses
- self.assertTrue(niv_genesis_chapter_one.has_verse_list())
- self.assertEquals('In the beginning God created the heavens and the earth.',
- niv_genesis_chapter_one.verse_list[1],
- 'The first chapter of genesis should have been fetched.')
+ assert niv_genesis_chapter_one.has_verse_list() is True
+ assert 'In the beginning God created the heavens and the earth.' == niv_genesis_chapter_one.verse_list[1], \
+ 'The first chapter of genesis should have been fetched.'
=== modified file 'tests/interfaces/openlp_plugins/bibles/test_lib_manager.py'
--- tests/interfaces/openlp_plugins/bibles/test_lib_manager.py 2017-10-07 07:05:07 +0000
+++ tests/interfaces/openlp_plugins/bibles/test_lib_manager.py 2017-12-23 09:39:35 +0000
@@ -79,7 +79,7 @@
# WHEN asking for the books of the bible
books = self.manager.get_books('tests')
# THEN a list of books should be returned
- self.assertEqual(66, len(books), 'There should be 66 books in the bible')
+ assert 66 == len(books), 'There should be 66 books in the bible'
def test_get_book_by_id(self):
"""
@@ -89,7 +89,7 @@
# WHEN asking for the book of the bible
book = self.manager.get_book_by_id('tests', 54)
# THEN a book should be returned
- self.assertEqual('1 Timothy', book.name, '1 Timothy should have been returned from the bible')
+ assert '1 Timothy' == book.name, '1 Timothy should have been returned from the bible'
def test_get_chapter_count(self):
"""
@@ -100,7 +100,7 @@
book = self.manager.get_book_by_id('tests', 54)
chapter = self.manager.get_chapter_count('tests', book)
# THEN the chapter count should be returned
- self.assertEqual(6, chapter, '1 Timothy should have 6 chapters returned from the bible')
+ assert 6 == chapter, '1 Timothy should have 6 chapters returned from the bible'
def test_get_verse_count_by_book_ref_id(self):
"""
@@ -110,4 +110,4 @@
# WHEN asking for the number of verses in a book of the bible
verses = self.manager.get_verse_count_by_book_ref_id('tests', 54, 3)
# THEN the chapter count should be returned
- self.assertEqual(16, verses, '1 Timothy v3 should have 16 verses returned from the bible')
+ assert 16 == verses, '1 Timothy v3 should have 16 verses returned from the bible'
=== modified file 'tests/interfaces/openlp_plugins/bibles/test_lib_parse_reference.py'
--- tests/interfaces/openlp_plugins/bibles/test_lib_parse_reference.py 2017-10-07 07:05:07 +0000
+++ tests/interfaces/openlp_plugins/bibles/test_lib_parse_reference.py 2017-12-23 09:39:35 +0000
@@ -79,7 +79,7 @@
# WHEN asking to parse the bible reference
results = parse_reference('1 Timothy 1', self.manager.db_cache['tests'], MagicMock(), 54)
# THEN a verse array should be returned
- self.assertEqual([(54, 1, 1, -1)], results, "The bible verses should matches the expected results")
+ assert [(54, 1, 1, -1)] == results, "The bible verses should matches the expected results"
def test_parse_reference_two(self):
"""
@@ -89,7 +89,7 @@
# WHEN asking to parse the bible reference
results = parse_reference('1 Timothy 1:1-2', self.manager.db_cache['tests'], MagicMock(), 54)
# THEN a verse array should be returned
- self.assertEqual([(54, 1, 1, 2)], results, "The bible verses should matches the expected results")
+ assert [(54, 1, 1, 2)] == results, "The bible verses should matches the expected results"
def test_parse_reference_three(self):
"""
@@ -99,8 +99,8 @@
# WHEN asking to parse the bible reference
results = parse_reference('1 Timothy 1:1-2:1', self.manager.db_cache['tests'], MagicMock(), 54)
# THEN a verse array should be returned
- self.assertEqual([(54, 1, 1, -1), (54, 2, 1, 1)], results,
- "The bible verses should match the expected results")
+ assert [(54, 1, 1, -1), (54, 2, 1, 1)] == results, \
+ "The bible verses should match the expected results"
def test_parse_reference_four(self):
"""
@@ -110,7 +110,7 @@
# WHEN asking to parse the bible reference
results = parse_reference('Raoul 1', self.manager.db_cache['tests'], MagicMock())
# THEN a verse array should be returned
- self.assertEqual([], results, "The bible Search should return an empty list")
+ assert [] == results, "The bible Search should return an empty list"
def test_parse_reference_five(self):
"""
@@ -120,4 +120,4 @@
# WHEN asking to parse the bible reference
results = parse_reference('1 Timothy 1:3-end', self.manager.db_cache['tests'], MagicMock(), 54)
# THEN a verse array should be returned
- self.assertEqual([(54, 1, 3, -1)], results, "The bible verses should matches the expected results")
+ assert [(54, 1, 3, -1)] == results, "The bible verses should matches the expected results"
=== modified file 'tests/interfaces/openlp_plugins/custom/forms/test_customform.py'
--- tests/interfaces/openlp_plugins/custom/forms/test_customform.py 2017-10-07 07:05:07 +0000
+++ tests/interfaces/openlp_plugins/custom/forms/test_customform.py 2017-12-23 09:39:35 +0000
@@ -78,8 +78,8 @@
self.form.load_custom(0)
# THEN: The line edits should not contain any text.
- self.assertEqual(self.form.title_edit.text(), '', 'The title edit should be empty')
- self.assertEqual(self.form.credit_edit.text(), '', 'The credit edit should be empty')
+ assert self.form.title_edit.text() == '', 'The title edit should be empty'
+ assert self.form.credit_edit.text() == '', 'The credit edit should be empty'
def test_on_add_button_clicked(self):
"""
=== modified file 'tests/interfaces/openlp_plugins/songs/forms/test_authorsform.py'
--- tests/interfaces/openlp_plugins/songs/forms/test_authorsform.py 2017-10-07 07:05:07 +0000
+++ tests/interfaces/openlp_plugins/songs/forms/test_authorsform.py 2017-12-23 09:39:35 +0000
@@ -58,9 +58,9 @@
"""
Test the AuthorForm defaults are correct
"""
- self.assertEqual(self.form.first_name_edit.text(), '', 'The first name edit should be empty')
- self.assertEqual(self.form.last_name_edit.text(), '', 'The last name edit should be empty')
- self.assertEqual(self.form.display_edit.text(), '', 'The display name edit should be empty')
+ assert self.form.first_name_edit.text() == '', 'The first name edit should be empty'
+ assert self.form.last_name_edit.text() == '', 'The last name edit should be empty'
+ assert self.form.display_edit.text() == '', 'The display name edit should be empty'
def test_get_first_name_property(self):
"""
@@ -73,7 +73,7 @@
self.form.first_name_edit.setText(first_name)
# THEN: The first_name property should have the correct value
- self.assertEqual(self.form.first_name, first_name, 'The first name property should be correct')
+ assert self.form.first_name == first_name, 'The first name property should be correct'
def test_set_first_name_property(self):
"""
@@ -86,7 +86,7 @@
self.form.first_name = first_name
# THEN: The first_name_edit should have the correct value
- self.assertEqual(self.form.first_name_edit.text(), first_name, 'The first name should be set correctly')
+ assert self.form.first_name_edit.text() == first_name, 'The first name should be set correctly'
def test_get_last_name_property(self):
"""
@@ -99,7 +99,7 @@
self.form.last_name_edit.setText(last_name)
# THEN: The last_name property should have the correct value
- self.assertEqual(self.form.last_name, last_name, 'The last name property should be correct')
+ assert self.form.last_name == last_name, 'The last name property should be correct'
def test_set_last_name_property(self):
"""
@@ -112,7 +112,7 @@
self.form.last_name = last_name
# THEN: The last_name_edit should have the correct value
- self.assertEqual(self.form.last_name_edit.text(), last_name, 'The last name should be set correctly')
+ assert self.form.last_name_edit.text() == last_name, 'The last name should be set correctly'
def test_get_display_name_property(self):
"""
@@ -125,7 +125,7 @@
self.form.display_edit.setText(display_name)
# THEN: The display_name property should have the correct value
- self.assertEqual(self.form.display_name, display_name, 'The display name property should be correct')
+ assert self.form.display_name == display_name, 'The display name property should be correct'
def test_set_display_name_property(self):
"""
@@ -138,7 +138,7 @@
self.form.display_name = display_name
# THEN: The display_name_edit should have the correct value
- self.assertEqual(self.form.display_edit.text(), display_name, 'The display name should be set correctly')
+ assert self.form.display_edit.text() == display_name, 'The display name should be set correctly'
@patch('openlp.plugins.songs.forms.authorsform.QtWidgets.QDialog.exec')
def test_exec(self, mocked_exec):
=== modified file 'tests/interfaces/openlp_plugins/songs/forms/test_editsongform.py'
--- tests/interfaces/openlp_plugins/songs/forms/test_editsongform.py 2017-10-07 07:05:07 +0000
+++ tests/interfaces/openlp_plugins/songs/forms/test_editsongform.py 2017-12-23 09:39:35 +0000
@@ -69,10 +69,10 @@
"""
Test that the EditSongForm defaults are correct
"""
- self.assertFalse(self.form.verse_edit_button.isEnabled(), 'The verse edit button should not be enabled')
- self.assertFalse(self.form.verse_delete_button.isEnabled(), 'The verse delete button should not be enabled')
- self.assertFalse(self.form.author_remove_button.isEnabled(), 'The author remove button should not be enabled')
- self.assertFalse(self.form.topic_remove_button.isEnabled(), 'The topic remove button should not be enabled')
+ assert self.form.verse_edit_button.isEnabled() is False, 'The verse edit button should not be enabled'
+ assert self.form.verse_delete_button.isEnabled() is False, 'The verse delete button should not be enabled'
+ assert self.form.author_remove_button.isEnabled() is False, 'The author remove button should not be enabled'
+ assert self.form.topic_remove_button.isEnabled() is False, 'The topic remove button should not be enabled'
def test_is_verse_edit_form_executed(self):
pass
@@ -147,10 +147,10 @@
# GIVEN; Mocked methods
form = self.form
# THEN: CCLI label should be CCLI song label
- self.assertNotEquals(form.ccli_label.text(), UiStrings().CCLINumberLabel,
- 'CCLI label should not be "{}"'.format(UiStrings().CCLINumberLabel))
- self.assertEquals(form.ccli_label.text(), UiStrings().CCLISongNumberLabel,
- 'CCLI label text should be "{}"'.format(UiStrings().CCLISongNumberLabel))
+ assert form.ccli_label.text() is not UiStrings().CCLINumberLabel, \
+ 'CCLI label should not be "{}"'.format(UiStrings().CCLINumberLabel)
+ assert form.ccli_label.text() == UiStrings().CCLISongNumberLabel, \
+ 'CCLI label text should be "{}"'.format(UiStrings().CCLISongNumberLabel)
def test_verse_order_lowercase(self):
"""
@@ -165,4 +165,4 @@
form.on_verse_order_text_changed(form.verse_order_edit.text())
# THEN: The verse order should be converted to uppercase
- self.assertEqual(form.verse_order_edit.text(), 'V1 V2 C1 V3 C1 V4 C1')
+ assert form.verse_order_edit.text() == 'V1 V2 C1 V3 C1 V4 C1'
=== modified file 'tests/interfaces/openlp_plugins/songs/forms/test_editverseform.py'
--- tests/interfaces/openlp_plugins/songs/forms/test_editverseform.py 2017-10-07 07:05:07 +0000
+++ tests/interfaces/openlp_plugins/songs/forms/test_editverseform.py 2017-12-23 09:39:35 +0000
@@ -68,7 +68,7 @@
# GIVEN: An EditVerseForm instance
# WHEN: The form is shown
# THEN: The default value is correct
- self.assertEqual(self.form.verse_text_edit.toPlainText(), '', 'The verse edit box is empty.')
+ assert self.form.verse_text_edit.toPlainText() == '', 'The verse edit box is empty.'
def test_type_verse_text(self):
"""
@@ -81,8 +81,8 @@
QtTest.QTest.keyClicks(self.form.verse_text_edit, text)
# THEN: The verse text edit should have the verse text in it
- self.assertEqual(text, self.form.verse_text_edit.toPlainText(),
- 'The verse text edit should have the typed out verse')
+ assert text == self.form.verse_text_edit.toPlainText(), \
+ 'The verse text edit should have the typed out verse'
def test_insert_verse(self):
"""
@@ -93,8 +93,8 @@
QtTest.QTest.mouseClick(self.form.insert_button, QtCore.Qt.LeftButton)
# THEN: The verse text edit should have a Verse:1 in it
- self.assertIn('---[Verse:1]---', self.form.verse_text_edit.toPlainText(),
- 'The verse text edit should have a verse marker')
+ assert '---[Verse:1]---' in self.form.verse_text_edit.toPlainText(), \
+ 'The verse text edit should have a verse marker'
def test_insert_verse_2(self):
"""
@@ -106,8 +106,8 @@
QtTest.QTest.mouseClick(self.form.insert_button, QtCore.Qt.LeftButton)
# THEN: The verse text edit should have a Verse:1 in it
- self.assertIn('---[Verse:2]---', self.form.verse_text_edit.toPlainText(),
- 'The verse text edit should have a "Verse 2" marker')
+ assert '---[Verse:2]---' in self.form.verse_text_edit.toPlainText(), \
+ 'The verse text edit should have a "Verse 2" marker'
def test_insert_chorus(self):
"""
@@ -119,5 +119,5 @@
QtTest.QTest.mouseClick(self.form.insert_button, QtCore.Qt.LeftButton)
# THEN: The verse text edit should have a Chorus:1 in it
- self.assertIn('---[Chorus:1]---', self.form.verse_text_edit.toPlainText(),
- 'The verse text edit should have a "Chorus 1" marker')
+ assert '---[Chorus:1]---' in self.form.verse_text_edit.toPlainText(), \
+ 'The verse text edit should have a "Chorus 1" marker'
=== modified file 'tests/interfaces/openlp_plugins/songs/forms/test_topicsform.py'
--- tests/interfaces/openlp_plugins/songs/forms/test_topicsform.py 2017-10-07 07:05:07 +0000
+++ tests/interfaces/openlp_plugins/songs/forms/test_topicsform.py 2017-12-23 09:39:35 +0000
@@ -57,7 +57,7 @@
"""
Test the TopicsForm defaults are correct
"""
- self.assertEqual(self.form.name_edit.text(), '', 'The first name edit should be empty')
+ assert self.form.name_edit.text() == '', 'The first name edit should be empty'
def test_get_name_property(self):
"""
@@ -70,7 +70,7 @@
self.form.name_edit.setText(topic_name)
# THEN: The name property should have the correct value
- self.assertEqual(self.form.name, topic_name, 'The name property should be correct')
+ assert self.form.name == topic_name, 'The name property should be correct'
def test_set_name_property(self):
"""
@@ -83,4 +83,4 @@
self.form.name = topic_name
# THEN: The name_edit should have the correct value
- self.assertEqual(self.form.name_edit.text(), topic_name, 'The topic name should be set correctly')
+ assert self.form.name_edit.text() == topic_name, 'The topic name should be set correctly'
=== modified file 'tests/utils/test_bzr_tags.py'
--- tests/utils/test_bzr_tags.py 2016-12-31 11:01:36 +0000
+++ tests/utils/test_bzr_tags.py 2017-12-23 09:39:35 +0000
@@ -52,4 +52,4 @@
count1 += 1
# THEN the tags should match the accepted tags
- self.assertEqual(count, count1, 'List of tags should match')
+ assert count == count1, 'List of tags should match'
=== modified file 'tests/utils/test_pylint.py'
--- tests/utils/test_pylint.py 2017-11-10 04:11:03 +0000
+++ tests/utils/test_pylint.py 2017-12-23 09:39:35 +0000
@@ -80,7 +80,7 @@
print(stderr)
# THEN: The output should be empty
- self.assertTrue(filtered_stdout == '', 'PyLint should find no errors')
+ assert filtered_stdout == '', 'PyLint should find no errors'
def _filter_tolerated_errors(self, pylint_output):
"""
Follow ups