almost finished

This commit is contained in:
Tim Bentley 2017-12-23 09:09:45 +00:00
parent 17b62ee6c9
commit 6729e78231
36 changed files with 192 additions and 205 deletions

View File

@ -141,7 +141,7 @@ class TestCategoryActionList(TestCase):
assert self.action1 not in self.list
# THEN: Check if an exception is raised when trying to remove a not present action.
self.assertRaises(ValueError, self.list.remove, self.action2)
assertRaises(ValueError, self.list.remove, self.action2)
class TestActionList(TestCase, TestMixin):

View File

@ -183,7 +183,7 @@ class TestInit(TestCase, TestMixin):
# WHEN: Calling get_uno_command
# THEN: a FileNotFoundError exception should be raised
self.assertRaises(FileNotFoundError, get_uno_command)
assertRaises(FileNotFoundError, get_uno_command)
def test_get_uno_command_connection_type(self):
"""

View File

@ -72,13 +72,13 @@ class TestImageManager(TestCase, TestMixin):
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 @@ class TestImageManager(TestCase, TestMixin):
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:

View File

@ -291,7 +291,7 @@ class TestLib(TestCase):
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 @@ class TestLib(TestCase):
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 @@ class TestLib(TestCase):
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 @@ class TestLib(TestCase):
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 @@ class TestLib(TestCase):
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):
"""

View File

@ -52,7 +52,7 @@ class TestPath(TestCase):
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 @@ class TestPath(TestCase):
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 @@ class TestPath(TestCase):
result = str_to_path('')
# THEN: `path_to_str` should return None
self.assertEqual(result, None)
assert result is None

View File

@ -159,7 +159,7 @@ class TestProjectorDB(TestCase):
record = self.projector.get_projector_by_ip(TEST2_DATA['ip'])
# THEN: Verify proper record returned
self.assertTrue(compare_data(Projector(**TEST2_DATA), record),
assertTrue(compare_data(Projector(**TEST2_DATA), record),
'Record found should have been test_2 data')
def test_find_record_by_name(self):
@ -173,7 +173,7 @@ class TestProjectorDB(TestCase):
record = self.projector.get_projector_by_name(TEST2_DATA['name'])
# THEN: Verify proper record returned
self.assertTrue(compare_data(Projector(**TEST2_DATA), record),
assertTrue(compare_data(Projector(**TEST2_DATA), record),
'Record found should have been test_2 data')
def test_record_delete(self):
@ -189,7 +189,7 @@ class TestProjectorDB(TestCase):
# THEN: Verify record not retrievable
found = self.projector.get_projector_by_ip(TEST3_DATA['ip'])
self.assertFalse(found, 'test_3 record should have been deleted')
assertFalse(found, 'test_3 record should have been deleted')
def test_record_edit(self):
"""
@ -214,7 +214,7 @@ class TestProjectorDB(TestCase):
record.model_filter = TEST3_DATA['model_filter']
record.model_lamp = TEST3_DATA['model_lamp']
updated = self.projector.update_projector(record)
self.assertTrue(updated, 'Save updated record should have returned True')
assertTrue(updated, 'Save updated record should have returned True')
record = self.projector.get_projector_by_ip(TEST3_DATA['ip'])
# THEN: Record ID should remain the same, but data should be changed

View File

@ -117,8 +117,8 @@ class TestMainWindow(TestCase, TestMixin):
# 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 @@ class TestMainWindow(TestCase, TestMixin):
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')

View File

@ -402,7 +402,7 @@ class TestListPreviewWidget(TestCase):
list_preview_widget.row_resized(0, 100, 150)
# THEN: self.cellWidget(row, 0).children()[1].setMaximumWidth() should fail
self.assertRaises(Exception)
assertRaises(Exception)
@patch(u'openlp.core.widgets.views.ListPreviewWidget.selectRow')
@patch(u'openlp.core.widgets.views.ListPreviewWidget.scrollToItem')

View File

@ -79,5 +79,5 @@ class TestAlertManager(TestCase):
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')

View File

@ -217,7 +217,7 @@ class TestEasyWorshipSongImport(TestCase):
for field_name in non_existing_fields:
# THEN: The importer object should not be None
self.assertRaises(IndexError, importer.db_find_field, field_name)
assertRaises(IndexError, importer.db_find_field, field_name)
def test_set_record_struct(self):
"""

View File

@ -153,7 +153,7 @@ class TestOpenLyricsImport(TestCase, TestMixin):
ol._process_formatting_tags(song_xml, False)
# THEN: New tags should have been saved
self.assertListEqual(json.loads(json.dumps(result_tags)),
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')

View File

@ -45,8 +45,8 @@ class TestSongUsage(TestCase):
# THEN: about() should return a string object
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)
assertNotEquals(len(SongUsagePlugin.about()), 0)
assertNotEquals(len(SongUsagePlugin.about()), 0)
@patch('openlp.plugins.songusage.songusageplugin.Manager')
def test_song_usage_init(self, MockedManager):

View File

@ -108,7 +108,7 @@ class SongImportTestHelper(TestCase):
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 @@ class SongImportTestHelper(TestCase):
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 @@ class SongImportTestHelper(TestCase):
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):

View File

@ -86,11 +86,11 @@ class TestPluginManager(TestCase, TestMixin):
# 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')
assertIn('songs', plugin_names, 'There should be a "songs" plugin')
assertIn('bibles', plugin_names, 'There should be a "bibles" plugin')
assertIn('presentations', plugin_names, 'There should be a "presentations" plugin')
assertIn('images', plugin_names, 'There should be a "images" plugin')
assertIn('media', plugin_names, 'There should be a "media" plugin')
assertIn('custom', plugin_names, 'There should be a "custom" plugin')
assertIn('songusage', plugin_names, 'There should be a "songusage" plugin')
assertIn('alerts', plugin_names, 'There should be a "alerts" plugin')

View File

@ -46,5 +46,4 @@ class TestMediainfoWrapper(TestCase):
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]

View File

@ -63,19 +63,19 @@ class TestStartFileRenameForm(TestCase, TestMixin):
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 @@ class TestStartFileRenameForm(TestCase, TestMixin):
# 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'

View File

@ -70,8 +70,8 @@ class TestProjectorManager(TestCase, TestMixin):
# 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 @@ class TestProjectorManager(TestCase, TestMixin):
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'

View File

@ -111,8 +111,7 @@ class ProjectorSourceFormTest(TestCase, TestMixin):
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 @@ class ProjectorSourceFormTest(TestCase, TestMixin):
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 @@ class ProjectorSourceFormTest(TestCase, TestMixin):
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'

View File

@ -79,8 +79,8 @@ class TestServiceManager(TestCase, TestMixin):
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 @@ class TestServiceManager(TestCase, TestMixin):
# 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 @@ class TestServiceManager(TestCase, TestMixin):
# 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 is True, \
'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 @@ class TestServiceManager(TestCase, TestMixin):
# 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 is True, \
'Top item should have been selected'
self.service_manager.collapsed.assert_called_once_with(song_item)

View File

@ -66,7 +66,7 @@ class TestStartNoteDialog(TestCase, TestMixin):
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 @@ class TestStartNoteDialog(TestCase, TestMixin):
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 @@ class TestStartNoteDialog(TestCase, TestMixin):
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'

View File

@ -67,9 +67,9 @@ class TestShortcutform(TestCase, TestMixin):
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 @@ class TestShortcutform(TestCase, TestMixin):
# 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 @@ class TestShortcutform(TestCase, TestMixin):
# 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 @@ class TestShortcutform(TestCase, TestMixin):
# 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 @@ class TestShortcutform(TestCase, TestMixin):
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 @@ class TestShortcutform(TestCase, TestMixin):
# 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 @@ class TestShortcutform(TestCase, TestMixin):
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):
"""

View File

@ -56,28 +56,24 @@ class TestStartTimeDialog(TestCase, TestMixin):
"""
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 @@ class TestStartTimeDialog(TestCase, TestMixin):
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 @@ class TestStartTimeDialog(TestCase, TestMixin):
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'

View File

@ -121,4 +121,4 @@ class TestThemeManager(TestCase, TestMixin):
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"

View File

@ -86,8 +86,8 @@ class TestSearchEdit(TestCase, TestMixin):
# 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 @@ class TestSearchEdit(TestCase, TestMixin):
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 @@ class TestHistoryComboBox(TestCase, TestMixin):
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']

View File

@ -64,7 +64,7 @@ class TestListPreviewWidget(TestCase, TestMixin):
# 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 @@ class TestListPreviewWidget(TestCase, TestMixin):
# 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 @@ class TestListPreviewWidget(TestCase, TestMixin):
# 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 @@ class TestListPreviewWidget(TestCase, TestMixin):
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.'

View File

@ -78,7 +78,7 @@ class TestBibleImportForm(TestCase, TestMixin):
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):
"""

View File

@ -53,8 +53,8 @@ class TestBibleHTTP(TestCase):
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 @@ class TestBibleHTTP(TestCase):
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 @@ class TestBibleHTTP(TestCase):
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 @@ class TestBibleHTTP(TestCase):
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 @@ class TestBibleHTTP(TestCase):
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 @@ class TestBibleHTTP(TestCase):
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 @@ class TestBibleHTTP(TestCase):
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 @@ class TestBibleHTTP(TestCase):
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 @@ class TestBibleHTTP(TestCase):
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 @@ class TestBibleHTTP(TestCase):
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.'

View File

@ -79,7 +79,7 @@ class TestBibleManager(TestCase, TestMixin):
# 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 @@ class TestBibleManager(TestCase, TestMixin):
# 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 @@ class TestBibleManager(TestCase, TestMixin):
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 @@ class TestBibleManager(TestCase, TestMixin):
# 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'

View File

@ -79,7 +79,7 @@ class TestBibleManager(TestCase, TestMixin):
# 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 @@ class TestBibleManager(TestCase, TestMixin):
# 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 @@ class TestBibleManager(TestCase, TestMixin):
# 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 @@ class TestBibleManager(TestCase, TestMixin):
# 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 @@ class TestBibleManager(TestCase, TestMixin):
# 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"

View File

@ -78,8 +78,8 @@ class TestEditCustomForm(TestCase, TestMixin):
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):
"""

View File

@ -58,9 +58,9 @@ class TestAuthorsForm(TestCase, TestMixin):
"""
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 @@ class TestAuthorsForm(TestCase, TestMixin):
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 @@ class TestAuthorsForm(TestCase, TestMixin):
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 @@ class TestAuthorsForm(TestCase, TestMixin):
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 @@ class TestAuthorsForm(TestCase, TestMixin):
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 @@ class TestAuthorsForm(TestCase, TestMixin):
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 @@ class TestAuthorsForm(TestCase, TestMixin):
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):

View File

@ -69,10 +69,10 @@ class TestEditSongForm(TestCase, TestMixin):
"""
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 @@ class TestEditSongForm(TestCase, TestMixin):
# 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 @@ class TestEditSongForm(TestCase, TestMixin):
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'

View File

@ -68,7 +68,7 @@ class TestEditVerseForm(TestCase, TestMixin):
# 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 @@ class TestEditVerseForm(TestCase, TestMixin):
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 @@ class TestEditVerseForm(TestCase, TestMixin):
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 @@ class TestEditVerseForm(TestCase, TestMixin):
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 @@ class TestEditVerseForm(TestCase, TestMixin):
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'

View File

@ -57,7 +57,7 @@ class TestTopicsForm(TestCase, TestMixin):
"""
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 @@ class TestTopicsForm(TestCase, TestMixin):
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 @@ class TestTopicsForm(TestCase, TestMixin):
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'

View File

@ -52,4 +52,4 @@ class TestBzrTags(TestCase):
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'

View File

@ -80,7 +80,7 @@ class TestPylint(TestCase):
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):
"""