From 9f735e0cc5524b559d4e08f92bc0960fe6e085a3 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 17 Dec 2017 15:35:35 +0000 Subject: [PATCH] 1 more done --- .../openlp_core/lib/test_exceptions.py | 2 +- .../openlp_core/lib/test_htmlbuilder.py | 22 +-- .../openlp_core/lib/test_image_manager.py | 30 ++-- tests/functional/openlp_core/lib/test_lib.py | 149 +++++++++--------- 4 files changed, 97 insertions(+), 106 deletions(-) diff --git a/tests/functional/openlp_core/lib/test_exceptions.py b/tests/functional/openlp_core/lib/test_exceptions.py index c0de323b7..7ffc122c1 100644 --- a/tests/functional/openlp_core/lib/test_exceptions.py +++ b/tests/functional/openlp_core/lib/test_exceptions.py @@ -42,4 +42,4 @@ class TestValidationError(TestCase): # THEN: Then calling str on the error should return the correct text and it should be an instance of `Exception` assert str(error) == 'Test ValidationError' - assert isinstance(error, Exception) + assert isinstance(error, Exception) is True diff --git a/tests/functional/openlp_core/lib/test_htmlbuilder.py b/tests/functional/openlp_core/lib/test_htmlbuilder.py index 7c8d7809f..ffd796ecb 100644 --- a/tests/functional/openlp_core/lib/test_htmlbuilder.py +++ b/tests/functional/openlp_core/lib/test_htmlbuilder.py @@ -309,7 +309,7 @@ class Htmbuilder(TestCase, TestMixin): html = build_html(item, screen, is_live, background, plugins=plugins) # THEN: The returned html should match. - self.assertEqual(html, HTML, 'The returned html should match') + assert html == HTML, 'The returned html should match' def test_build_background_css_radial(self): """ @@ -325,7 +325,7 @@ class Htmbuilder(TestCase, TestMixin): css = build_background_css(item, width) # THEN: The returned css should match. - self.assertEqual(BACKGROUND_CSS_RADIAL, css, 'The background css should be equal.') + assert BACKGROUND_CSS_RADIAL == css, 'The background css should be equal.' def test_build_lyrics_css(self): """ @@ -346,7 +346,7 @@ class Htmbuilder(TestCase, TestMixin): css = build_lyrics_css(item) # THEN: The css should be equal. - self.assertEqual(LYRICS_CSS, css, 'The lyrics css should be equal.') + assert LYRICS_CSS == css, 'The lyrics css should be equal.' def test_build_lyrics_outline_css(self): """ @@ -363,7 +363,7 @@ class Htmbuilder(TestCase, TestMixin): css = build_lyrics_outline_css(theme_data) # THEN: The css should be equal. - self.assertEqual(LYRICS_OUTLINE_CSS, css, 'The outline css should be equal.') + assert LYRICS_OUTLINE_CSS == css, 'The outline css should be equal.' def test_build_lyrics_format_css(self): """ @@ -386,7 +386,7 @@ class Htmbuilder(TestCase, TestMixin): css = build_lyrics_format_css(theme_data, width, height) # THEN: They should be equal. - self.assertEqual(LYRICS_FORMAT_CSS, css, 'The lyrics format css should be equal.') + assert LYRICS_FORMAT_CSS == css, 'The lyrics format css should be equal.' def test_build_footer_css(self): """ @@ -404,7 +404,7 @@ class Htmbuilder(TestCase, TestMixin): css = build_footer_css(item, height) # THEN: THE css should be the same. - self.assertEqual(FOOTER_CSS, css, 'The footer strings should be equal.') + assert FOOTER_CSS == css, 'The footer strings should be equal.' def test_build_footer_css_wrap(self): """ @@ -423,7 +423,7 @@ class Htmbuilder(TestCase, TestMixin): css = build_footer_css(item, height) # THEN: Footer should wrap - self.assertEqual(FOOTER_CSS_WRAP, css, 'The footer strings should be equal.') + assert FOOTER_CSS_WRAP == css, 'The footer strings should be equal.' def test_build_footer_invalid(self): """ @@ -443,8 +443,8 @@ class Htmbuilder(TestCase, TestMixin): css.append(build_footer_css(item, height)) # THEN: Footer should wrap - self.assertEqual(FOOTER_CSS_INVALID, css[0], 'The footer strings should be blank.') - self.assertEqual(FOOTER_CSS_INVALID, css[1], 'The footer strings should be blank.') + assert FOOTER_CSS_INVALID == css[0], 'The footer strings should be blank.' + assert FOOTER_CSS_INVALID == css[1], 'The footer strings should be blank.' def test_webkit_version(self): """ @@ -454,7 +454,7 @@ class Htmbuilder(TestCase, TestMixin): webkit_ver = float(QtWebKit.qWebKitVersion()) # WHEN: Retrieving the webkit version # THEN: Webkit versions should match - self.assertEquals(webkit_version(), webkit_ver, "The returned webkit version doesn't match the installed one") + assert webkit_version() == webkit_ver, "The returned webkit version doesn't match the installed one" def test_build_chords_css(self): """ @@ -468,4 +468,4 @@ class Htmbuilder(TestCase, TestMixin): chord_css = build_chords_css() # THEN: The build css should look as expected - self.assertEqual(CHORD_CSS_ENABLED, chord_css, 'The chord CSS should look as expected') + assert CHORD_CSS_ENABLED == chord_css, 'The chord CSS should look as expected' diff --git a/tests/functional/openlp_core/lib/test_image_manager.py b/tests/functional/openlp_core/lib/test_image_manager.py index c39f6e8f4..0b37b412d 100644 --- a/tests/functional/openlp_core/lib/test_image_manager.py +++ b/tests/functional/openlp_core/lib/test_image_manager.py @@ -84,7 +84,7 @@ class TestImageManager(TestCase, TestMixin): # THEN a KeyError is thrown with self.assertRaises(KeyError) as context: self.image_manager.get_image(TEST_PATH, 'church1.jpg') - self.assertNotEquals(context.exception, '', 'KeyError exception should have been thrown for missing image') + assert context.exception is not '', 'KeyError exception should have been thrown for missing image' def test_different_dimension_image(self): """ @@ -98,7 +98,7 @@ class TestImageManager(TestCase, TestMixin): image = self.image_manager.get_image(full_path, 'church.jpg', 80, 80) # THEN: The return should be of type image - self.assertEqual(isinstance(image, QtGui.QImage), True, 'The returned object should be a QImage') + assert isinstance(image, QtGui.QImage) is True, 'The returned object should be a QImage' # WHEN: adding the same image with different dimensions self.image_manager.add_image(full_path, 'church.jpg', None, 100, 100) @@ -116,7 +116,7 @@ class TestImageManager(TestCase, TestMixin): # WHEN: calling with correct image, but wrong dimensions with self.assertRaises(KeyError) as context: self.image_manager.get_image(full_path, 'church.jpg', 120, 120) - self.assertNotEquals(context.exception, '', 'KeyError exception should have been thrown for missing dimension') + assert context.exception is not '', 'KeyError exception should have been thrown for missing dimension' def test_process_cache(self): """ @@ -141,10 +141,8 @@ class TestImageManager(TestCase, TestMixin): # is being processed (see mocked methods/functions). # Note: Priority.Normal means, that the resize_image() was not completed yet (because afterwards the # # priority is adjusted to Priority.Lowest). - self.assertEqual(self.get_image_priority(image1), Priority.Normal, - "image1's priority should be 'Priority.Normal'") - self.assertEqual(self.get_image_priority(image2), Priority.Normal, - "image2's priority should be 'Priority.Normal'") + assert self.get_image_priority(image1) == Priority.Normal, "image1's priority should be 'Priority.Normal'" + assert self.get_image_priority(image2) == Priority.Normal, "image2's priority should be 'Priority.Normal'" # WHEN: Add more images. self.image_manager.add_image(TEST_PATH, image3, None) @@ -162,15 +160,15 @@ class TestImageManager(TestCase, TestMixin): # Because empty() is not reliable, wait a litte; just to make sure. time.sleep(0.1) # THEN: The images' priority reflect how they were processed. - self.assertEqual(self.image_manager._conversion_queue.qsize(), 0, "The queue should be empty.") - self.assertEqual(self.get_image_priority(image1), Priority.Lowest, - "The image should have not been requested (=Lowest)") - self.assertEqual(self.get_image_priority(image2), Priority.Lowest, - "The image should have not been requested (=Lowest)") - self.assertEqual(self.get_image_priority(image3), Priority.Low, - "Only the QImage should have been requested (=Low).") - self.assertEqual(self.get_image_priority(image4), Priority.Urgent, - "The image bytes should have been requested (=Urgent).") + assert self.image_manager._conversion_queue.qsize() == 0, "The queue should be empty." + assert self.get_image_priority(image1) == Priority.Lowest, \ + "The image should have not been requested (=Lowest)" + assert self.get_image_priority(image2) == Priority.Lowest, \ + "The image should have not been requested (=Lowest)" + assert self.get_image_priority(image3) == Priority.Low, \ + "Only the QImage should have been requested (=Low)." + assert self.get_image_priority(image4) == Priority.Urgent, \ + "The image bytes should have been requested (=Urgent)." def get_image_priority(self, image): """ diff --git a/tests/functional/openlp_core/lib/test_lib.py b/tests/functional/openlp_core/lib/test_lib.py index e9788060e..9230ca5b0 100644 --- a/tests/functional/openlp_core/lib/test_lib.py +++ b/tests/functional/openlp_core/lib/test_lib.py @@ -49,8 +49,8 @@ class TestLib(TestCase): true_result = str_to_bool(true_boolean) # THEN: We should get back a True bool - self.assertIsInstance(true_result, bool, 'The result should be a boolean') - self.assertTrue(true_result, 'The result should be True') + assert isinstance(true_result, bool), 'The result should be a boolean' + assert true_result is True, 'The result should be True' def test_str_to_bool_with_bool_false(self): """ @@ -63,8 +63,8 @@ class TestLib(TestCase): false_result = str_to_bool(false_boolean) # THEN: We should get back a True bool - self.assertIsInstance(false_result, bool, 'The result should be a boolean') - self.assertFalse(false_result, 'The result should be True') + assert isinstance(false_result, bool), 'The result should be a boolean' + assert false_result is False, 'The result should be True' def test_str_to_bool_with_integer(self): """ @@ -77,7 +77,7 @@ class TestLib(TestCase): int_result = str_to_bool(int_string) # THEN: we should get back a false - self.assertFalse(int_result, 'The result should be False') + assert int_result is False, 'The result should be False' def test_str_to_bool_with_invalid_string(self): """ @@ -90,7 +90,7 @@ class TestLib(TestCase): str_result = str_to_bool(invalid_string) # THEN: we should get back a false - self.assertFalse(str_result, 'The result should be False') + assert str_result is False, 'The result should be False' def test_str_to_bool_with_string_false(self): """ @@ -103,7 +103,7 @@ class TestLib(TestCase): false_result = str_to_bool(false_string) # THEN: we should get back a false - self.assertFalse(false_result, 'The result should be False') + assert false_result is False, 'The result should be False' def test_str_to_bool_with_string_no(self): """ @@ -116,7 +116,7 @@ class TestLib(TestCase): str_result = str_to_bool(no_string) # THEN: we should get back a false - self.assertFalse(str_result, 'The result should be False') + assert str_result is False, 'The result should be False' def test_str_to_bool_with_true_string_value(self): """ @@ -129,7 +129,7 @@ class TestLib(TestCase): true_result = str_to_bool(true_string) # THEN: we should get back a true - self.assertTrue(true_result, 'The result should be True') + assert true_result is True, 'The result should be True' def test_str_to_bool_with_yes_string_value(self): """ @@ -142,7 +142,7 @@ class TestLib(TestCase): str_result = str_to_bool(yes_string) # THEN: we should get back a true - self.assertTrue(str_result, 'The result should be True') + assert str_result is True, 'The result should be True' def test_get_text_file_string_no_file(self): """ @@ -157,7 +157,7 @@ class TestLib(TestCase): # THEN: The result should be False file_path.is_file.assert_called_with() - self.assertFalse(result, 'False should be returned if no file exists') + assert result is False, 'False should be returned if no file exists' def test_get_text_file_string_read_error(self): """ @@ -176,7 +176,7 @@ class TestLib(TestCase): # THEN: None should be returned file_path.is_file.assert_called_once_with() file_path.open.assert_called_once_with('r', encoding='utf-8') - self.assertIsNone(result, 'None should be returned if the file cannot be opened') + assert result is None, 'None should be returned if the file cannot be opened' def test_get_text_file_string_decode_error(self): """ @@ -195,7 +195,7 @@ class TestLib(TestCase): result = build_icon(icon) # THEN: The result should be the same icon as we passed in - self.assertIs(icon, result, 'The result should be the same icon as we passed in') + assert icon is result, 'The result should be the same icon as we passed in' def test_build_icon_with_resource(self): """ @@ -217,7 +217,7 @@ class TestLib(TestCase): MockedQPixmap.assert_called_with(resource_uri) # There really should be more assert statements here but due to type checking and things they all break. The # best we can do is to assert that we get back a MagicMock object. - self.assertIsInstance(result, MagicMock, 'The result should be a MagicMock, because we mocked it out') + assert isinstance(result, MagicMock), 'The result should be a MagicMock, because we mocked it out' def test_image_to_byte(self): """ @@ -240,8 +240,8 @@ class TestLib(TestCase): MockedQtCore.QBuffer.assert_called_with(mocked_byte_array) mocked_buffer.open.assert_called_with('writeonly') mocked_image.save.assert_called_with(mocked_buffer, "PNG") - self.assertFalse(mocked_byte_array.toBase64.called) - self.assertEqual(mocked_byte_array, result, 'The mocked out byte array should be returned') + assert mocked_byte_array.toBase64.called is False + assert mocked_byte_array == result, 'The mocked out byte array should be returned' def test_image_to_byte_base_64(self): """ @@ -266,8 +266,7 @@ class TestLib(TestCase): mocked_buffer.open.assert_called_with('writeonly') mocked_image.save.assert_called_with(mocked_buffer, "PNG") mocked_byte_array.toBase64.assert_called_with() - self.assertEqual('base64mock', result, 'The result should be the return value of the mocked out ' - 'base64 method') + assert 'base64mock' == result, 'The result should be the return value of the mocked out base64 method' def test_create_thumb_with_size(self): """ @@ -286,16 +285,16 @@ class TestLib(TestCase): pass # Only continue when the thumb does not exist. - self.assertFalse(thumb_path.exists(), 'Test was not run, because the thumb already exists.') + assert thumb_path.exists() is False, 'Test was not run, because the thumb already exists.' # WHEN: Create the thumb. 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') - self.assertIsInstance(icon, QtGui.QIcon, 'The icon should be a QIcon') - self.assertFalse(icon.isNull(), 'The icon should not be null') - self.assertEqual(thumb_size, QtGui.QImageReader(str(thumb_path)).size(), 'The thumb should have the given size') + 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' # Remove the thumb so that the test actually tests if the thumb will be created. try: @@ -320,17 +319,16 @@ class TestLib(TestCase): pass # Only continue when the thumb does not exist. - self.assertFalse(thumb_path.exists(), 'Test was not run, because the thumb already exists.') + assert thumb_path.exists() is False, 'Test was not run, because the thumb already exists.' # WHEN: Create the thumb. 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') - self.assertIsInstance(icon, QtGui.QIcon, 'The icon should be a QIcon') - self.assertFalse(icon.isNull(), 'The icon should not be null') - self.assertEqual(expected_size, QtGui.QImageReader(str(thumb_path)).size(), - 'The thumb should have the given size') + 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' # Remove the thumb so that the test actually tests if the thumb will be created. try: @@ -356,17 +354,16 @@ class TestLib(TestCase): pass # Only continue when the thumb does not exist. - self.assertFalse(thumb_path.exists(), 'Test was not run, because the thumb already exists.') + assert thumb_path.exists() is False, 'Test was not run, because the thumb already exists.' # WHEN: Create the thumb. 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') - self.assertIsInstance(icon, QtGui.QIcon, 'The icon should be a QIcon') - self.assertFalse(icon.isNull(), 'The icon should not be null') - self.assertEqual(expected_size, QtGui.QImageReader(str(thumb_path)).size(), - 'The thumb should have the given size') + 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' # Remove the thumb so that the test actually tests if the thumb will be created. try: @@ -392,17 +389,16 @@ class TestLib(TestCase): pass # Only continue when the thumb does not exist. - self.assertFalse(thumb_path.exists(), 'Test was not run, because the thumb already exists.') + assert thumb_path.exists() is False, 'Test was not run, because the thumb already exists.' # WHEN: Create the thumb. 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') - self.assertIsInstance(icon, QtGui.QIcon, 'The icon should be a QIcon') - self.assertFalse(icon.isNull(), 'The icon should not be null') - self.assertEqual( - expected_size, QtGui.QImageReader(str(thumb_path)).size(), 'The thumb should have the given size') + 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' # Remove the thumb so that the test actually tests if the thumb will be created. try: @@ -428,17 +424,16 @@ class TestLib(TestCase): pass # Only continue when the thumb does not exist. - self.assertFalse(thumb_path.exists(), 'Test was not run, because the thumb already exists.') + assert thumb_path.exists() is False, 'Test was not run, because the thumb already exists.' # WHEN: Create the thumb. 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') - self.assertIsInstance(icon, QtGui.QIcon, 'The icon should be a QIcon') - self.assertFalse(icon.isNull(), 'The icon should not be null') - self.assertEqual( - expected_size, QtGui.QImageReader(str(thumb_path)).size(), 'The thumb should have the given size') + 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' # Remove the thumb so that the test actually tests if the thumb will be created. try: @@ -465,7 +460,7 @@ class TestLib(TestCase): pass # Only continue when the thumb does not exist. - self.assertFalse(thumb_path.exists(), 'Test was not run, because the thumb already exists.') + assert thumb_path.exists() is False, 'Test was not run, because the thumb already exists.' # WHEN: Create the thumb. with patch('openlp.core.lib.QtGui.QImageReader.size') as mocked_size: @@ -474,10 +469,9 @@ class TestLib(TestCase): # 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') - self.assertIsInstance(icon, QtGui.QIcon, 'The icon should be a QIcon') - self.assertFalse(icon.isNull(), 'The icon should not be null') - self.assertEqual( - expected_size_1, QtGui.QImageReader(str(thumb_path)).size(), 'The thumb should have the given size') + 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' # WHEN: Create the thumb. with patch('openlp.core.lib.QtGui.QImageReader.size') as mocked_size: @@ -485,10 +479,9 @@ class TestLib(TestCase): icon = create_thumb(image_path, thumb_path, size=thumb_size) # THEN: Check if the thumb was created with aspect ratio of 1. - self.assertIsInstance(icon, QtGui.QIcon, 'The icon should be a QIcon') - self.assertFalse(icon.isNull(), 'The icon should not be null') - self.assertEqual( - expected_size_2, QtGui.QImageReader(str(thumb_path)).size(), 'The thumb should have the given size') + 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_2 == QtGui.QImageReader(str(thumb_path)).size(), 'The thumb should have the given size' # Remove the thumb so that the test actually tests if the thumb will be created. try: @@ -511,7 +504,7 @@ class TestLib(TestCase): # THEN: The selectedIndexes function should have been called and the result should be true mocked_list_widget.selectedIndexes.assert_called_with() - self.assertTrue(result, 'The result should be True') + assert result is True, 'The result should be True' def test_check_item_selected_false(self): """ @@ -532,7 +525,7 @@ class TestLib(TestCase): # THEN: The selectedIndexes function should have been called and the result should be true mocked_list_widget.selectedIndexes.assert_called_with() MockedQtWidgets.QMessageBox.information.assert_called_with('parent', 'mocked translate', 'message') - self.assertFalse(result, 'The result should be False') + assert result is False, 'The result should be False' def test_clean_tags(self): """ @@ -554,7 +547,7 @@ class TestLib(TestCase): result_string = clean_tags(string_to_pass) # THEN: The strings should be identical. - self.assertEqual(wanted_string, result_string, 'The strings should be identical') + assert wanted_string == result_string, 'The strings should be identical' def test_expand_tags(self): """ @@ -593,7 +586,7 @@ class TestLib(TestCase): result_string = expand_tags(string_to_pass) # THEN: The strings should be identical. - self.assertEqual(wanted_string, result_string, 'The strings should be identical.') + assert wanted_string == result_string, 'The strings should be identical.' def test_validate_thumb_file_does_not_exist(self): """ @@ -609,7 +602,7 @@ class TestLib(TestCase): # THEN: we should have called a few functions, and the result should be False thumb_path.exists.assert_called_once_with() - self.assertFalse(result, 'The result should be False') + assert result is False, 'The result should be False' def test_validate_thumb_file_exists_and_newer(self): """ @@ -624,7 +617,7 @@ class TestLib(TestCase): result = validate_thumb(file_path, thumb_path) # THEN: `validate_thumb` should return True - self.assertTrue(result) + assert result is True def test_validate_thumb_file_exists_and_older(self): """ @@ -639,7 +632,7 @@ class TestLib(TestCase): # THEN: `validate_thumb` should return False thumb_path.stat.assert_called_once_with() - self.assertFalse(result, 'The result should be False') + assert result is False, 'The result should be False' def test_resize_thumb(self): """ @@ -658,9 +651,9 @@ class TestLib(TestCase): # THEN: Check if the size is correct and the background was set. result_size = image.size() - self.assertEqual(wanted_height, result_size.height(), 'The image should have the requested height.') - self.assertEqual(wanted_width, result_size.width(), 'The image should have the requested width.') - self.assertEqual(image.pixel(0, 0), wanted_background_rgb, 'The background should be white.') + assert wanted_height == result_size.height(), 'The image should have the requested height.' + assert wanted_width == result_size.width(), 'The image should have the requested width.' + assert image.pixel(0, 0) == wanted_background_rgb, 'The background should be white.' def test_resize_thumb_ignoring_aspect_ratio(self): """ @@ -679,9 +672,9 @@ class TestLib(TestCase): # THEN: Check if the size is correct and the background was set. result_size = image.size() - self.assertEqual(wanted_height, result_size.height(), 'The image should have the requested height.') - self.assertEqual(wanted_width, result_size.width(), 'The image should have the requested width.') - self.assertEqual(image.pixel(0, 0), wanted_background_rgb, 'The background should be white.') + assert wanted_height == result_size.height(), 'The image should have the requested height.' + assert wanted_width == result_size.width(), 'The image should have the requested width.' + assert image.pixel(0, 0) == wanted_background_rgb, 'The background should be white.' @patch('openlp.core.lib.QtCore.QLocale.createSeparatedList') def test_create_separated_list_qlocate(self, mocked_createSeparatedList): @@ -696,8 +689,8 @@ class TestLib(TestCase): string_result = create_separated_list(string_list) # THEN: We should have "Author 1, Author 2, and Author 3" - self.assertEqual(string_result, 'Author 1, Author 2 and Author 3', 'The string should be "Author 1, ' - 'Author 2, and Author 3".') + assert string_result == 'Author 1, Author 2 and Author 3', \ + 'The string should be "Author 1, Author 2, and Author 3".' def test_create_separated_list_empty_list(self): """ @@ -710,7 +703,7 @@ class TestLib(TestCase): string_result = create_separated_list(string_list) # THEN: We shoud have an emptry string. - self.assertEqual(string_result, '', 'The string sould be empty.') + assert string_result == '', 'The string sould be empty.' def test_create_separated_list_with_one_item(self): """ @@ -723,7 +716,7 @@ class TestLib(TestCase): string_result = create_separated_list(string_list) # THEN: We should have "Author 1" - self.assertEqual(string_result, 'Author 1', 'The string should be "Author 1".') + assert string_result == 'Author 1', 'The string should be "Author 1".' def test_create_separated_list_with_two_items(self): """ @@ -736,7 +729,7 @@ class TestLib(TestCase): string_result = create_separated_list(string_list) # THEN: We should have "Author 1 and Author 2" - self.assertEqual(string_result, 'Author 1 and Author 2', 'The string should be "Author 1 and Author 2".') + assert string_result == 'Author 1 and Author 2', 'The string should be "Author 1 and Author 2".' def test_create_separated_list_with_three_items(self): """ @@ -749,8 +742,8 @@ class TestLib(TestCase): string_result = create_separated_list(string_list) # THEN: We should have "Author 1, Author 2 and Author 3" - self.assertEqual(string_result, 'Author 1, Author 2 and Author 3', 'The string should be "Author 1, ' - 'Author 2, and Author 3".') + assert string_result == 'Author 1, Author 2 and Author 3', \ + 'The string should be "Author 1, Author 2, and Author 3".' def test_expand_chords(self): """ @@ -766,7 +759,7 @@ class TestLib(TestCase): expected_html = 'HC' \ 'alleluya.F' \ '   G' - self.assertEqual(expected_html, text_with_expanded_chords, 'The expanded chords should look as expected!') + assert expected_html == text_with_expanded_chords, 'The expanded chords should look as expected!' def test_expand_chords2(self): """ @@ -782,7 +775,7 @@ class TestLib(TestCase): expected_html = 'ID' \ ''M NOT MOVED BY WHAT I SEE HALLEF' \ 'LUJACH' - self.assertEqual(expected_html, text_with_expanded_chords, 'The expanded chords should look as expected!') + assert expected_html == text_with_expanded_chords, 'The expanded chords should look as expected!' def test_compare_chord_lyric_short_chord(self): """ @@ -810,7 +803,7 @@ class TestLib(TestCase): ret = compare_chord_lyric(chord, lyrics) # THEN: The returned value should 4 because the chord is longer than the lyric - self.assertEquals(4, ret, 'The returned value should 4 because the chord is longer than the lyric') + assert 4 == ret, 'The returned value should 4 because the chord is longer than the lyric' def test_find_formatting_tags(self): """ @@ -825,7 +818,7 @@ class TestLib(TestCase): active_tags = find_formatting_tags(lyrics, tags) # THEN: The list of active tags should contain only 'st' - self.assertListEqual(['st'], active_tags, 'The list of active tags should contain only "st"') + assert ['st'] == active_tags, 'The list of active tags should contain only "st"' def test_expand_chords_for_printing(self): """ @@ -862,4 +855,4 @@ class TestLib(TestCase): '' \ '
F
{st}{/st} 
' - self.assertEqual(expected_html, text_with_expanded_chords, 'The expanded chords should look as expected!') + assert expected_html == text_with_expanded_chords, 'The expanded chords should look as expected!'