Tim Bentley has proposed merging lp:~trb143/openlp/asserts into lp:openlp. Requested reviews: OpenLP Core (openlp-core)
For more details, see: https://code.launchpad.net/~trb143/openlp/asserts/+merge/335477 more assert updates and py.test fixes lp:~trb143/openlp/asserts (revision 2825) https://ci.openlp.io/job/Branch-01-Pull/2369/ [SUCCESS] https://ci.openlp.io/job/Branch-02-Functional-Tests/2270/ [SUCCESS] https://ci.openlp.io/job/Branch-03-Interface-Tests/2131/ [SUCCESS] https://ci.openlp.io/job/Branch-04a-Code_Analysis/1457/ [SUCCESS] https://ci.openlp.io/job/Branch-04b-Test_Coverage/1271/ [SUCCESS] https://ci.openlp.io/job/Branch-04c-Code_Analysis2/401/ [SUCCESS] https://ci.openlp.io/job/Branch-05-AppVeyor-Tests/230/ [FAILURE] -- Your team OpenLP Core is requested to review the proposed merge of lp:~trb143/openlp/asserts into lp:openlp.
=== modified file 'openlp/core/lib/__init__.py' --- openlp/core/lib/__init__.py 2017-11-18 22:40:05 +0000 +++ openlp/core/lib/__init__.py 2017-12-20 21:28:03 +0000 @@ -25,7 +25,6 @@ """ import html import logging -import os import re import math === modified file 'openlp/core/lib/mediamanageritem.py' --- openlp/core/lib/mediamanageritem.py 2017-11-20 21:57:34 +0000 +++ openlp/core/lib/mediamanageritem.py 2017-12-20 21:28:03 +0000 @@ -23,13 +23,12 @@ Provides the generic functions for interfacing plugins with the Media Manager. """ import logging -import os import re from PyQt5 import QtCore, QtWidgets from openlp.core.common.i18n import UiStrings, translate -from openlp.core.common.path import Path, path_to_str, str_to_path +from openlp.core.common.path import path_to_str, str_to_path from openlp.core.common.mixins import RegistryProperties from openlp.core.common.registry import Registry from openlp.core.common.settings import Settings === removed directory 'openlp/core/ui/lib' === modified file 'tests/functional/openlp_core/test_app.py' --- tests/functional/openlp_core/test_app.py 2017-10-23 22:09:57 +0000 +++ tests/functional/openlp_core/test_app.py 2017-12-20 21:28:03 +0000 @@ -289,9 +289,9 @@ result = self.openlp.event(event) # THEN: The path should be inserted. - self.assertTrue(result, "The method should have returned True.") + assert result is True, "The method should have returned True." mocked_file_method.assert_called_once_with() - self.assertEqual(self.openlp.args[0], file_path, "The path should be in args.") + assert self.openlp.args[0] == file_path, "The path should be in args." @patch('openlp.core.app.is_macosx') def test_application_activate_event(self, mocked_is_macosx): @@ -309,7 +309,7 @@ result = self.openlp.event(event) # THEN: - self.assertTrue(result, "The method should have returned True.") + assert result is True, "The method should have returned True." # self.assertFalse(self.openlp.main_window.isMinimized()) @patch('openlp.core.app.get_version') @@ -321,11 +321,11 @@ # GIVEN: Mocked data version and OpenLP version which are the same old_install = False MOCKED_VERSION = { - 'full': '2.2.0-bzr000', - 'version': '2.2.0', + 'full': '2.4.0-bzr000', + 'version': '2.4.0', 'build': 'bzr000' } - Settings().setValue('core/application version', '2.2.0') + Settings().setValue('core/application version', '2.4.0') mocked_get_version.return_value = MOCKED_VERSION mocked_question.return_value = QtWidgets.QMessageBox.No @@ -333,8 +333,8 @@ self.openlp.backup_on_upgrade(old_install, False) # THEN: It should not ask if we want to create a backup - self.assertEqual(Settings().value('core/application version'), '2.2.0', 'Version should be the same!') - self.assertEqual(mocked_question.call_count, 0, 'No question should have been asked!') + assert Settings().value('core/application version') == '2.4.0', 'Version should be the same!' + assert mocked_question.call_count == 0, 'No question should have been asked!' @patch('openlp.core.app.get_version') @patch('openlp.core.app.QtWidgets.QMessageBox.question') @@ -345,8 +345,8 @@ # GIVEN: Mocked data version and OpenLP version which are different old_install = True MOCKED_VERSION = { - 'full': '2.2.0-bzr000', - 'version': '2.2.0', + 'full': '2.4.0-bzr000', + 'version': '2.4.0', 'build': 'bzr000' } Settings().setValue('core/application version', '2.0.5') @@ -359,7 +359,7 @@ self.openlp.backup_on_upgrade(old_install, True) # THEN: It should ask if we want to create a backup - self.assertEqual(Settings().value('core/application version'), '2.2.0', 'Version should be upgraded!') - self.assertEqual(mocked_question.call_count, 1, 'A question should have been asked!') + assert Settings().value('core/application version') == '2.4.0', 'Version should be upgraded!' + assert mocked_question.call_count == 1, 'A question should have been asked!' self.openlp.splash.hide.assert_called_once_with() self.openlp.splash.show.assert_called_once_with() === removed directory 'tests/functional/openlp_core/ui/lib' === removed file 'tests/functional/openlp_core/ui/lib/__init__.py' === modified file 'tests/functional/openlp_core/ui/media/test_mediacontroller.py' --- tests/functional/openlp_core/ui/media/test_mediacontroller.py 2017-10-07 07:05:07 +0000 +++ tests/functional/openlp_core/ui/media/test_mediacontroller.py 2017-12-20 21:28:03 +0000 @@ -54,10 +54,10 @@ media_controller._generate_extensions_lists() # THEN: extensions list should have been copied from the player to the mediacontroller - self.assertListEqual(media_player.video_extensions_list, media_controller.video_extensions_list, - 'Video extensions should be the same') - self.assertListEqual(media_player.audio_extensions_list, media_controller.audio_extensions_list, - 'Audio extensions should be the same') + assert media_player.video_extensions_list == media_controller.video_extensions_list, \ + 'Video extensions should be the same' + assert media_player.audio_extensions_list == media_controller.audio_extensions_list, \ + 'Audio extensions should be the same' def test_resize(self): """ @@ -96,7 +96,7 @@ ret = media_controller._check_file_type(mocked_controller, mocked_display, mocked_service_item) # THEN: it should return False - self.assertFalse(ret, '_check_file_type should return False when no mediaplayers are available.') + assert ret is False, '_check_file_type should return False when no mediaplayers are available.' @patch('openlp.core.ui.media.mediacontroller.MediaController._get_used_players') @patch('openlp.core.ui.media.mediacontroller.UiStrings') @@ -119,7 +119,7 @@ ret = media_controller._check_file_type(mocked_controller, mocked_display, mocked_service_item) # THEN: it should return False - self.assertFalse(ret, '_check_file_type should return False when the processor for service_item is None.') + assert ret is False, '_check_file_type should return False when the processor for service_item is None.' @patch('openlp.core.ui.media.mediacontroller.MediaController._get_used_players') @patch('openlp.core.ui.media.mediacontroller.UiStrings') @@ -148,8 +148,8 @@ ret = media_controller._check_file_type(mocked_controller, mocked_display, mocked_service_item) # THEN: it should return True - self.assertTrue(ret, '_check_file_type should return True when mediaplayers are available and ' - 'the service item has an automatic processor.') + assert ret is True, '_check_file_type should return True when mediaplayers are available and ' \ + 'the service item has an automatic processor.' @patch('openlp.core.ui.media.mediacontroller.MediaController._get_used_players') @patch('openlp.core.ui.media.mediacontroller.UiStrings') @@ -178,8 +178,8 @@ ret = media_controller._check_file_type(mocked_controller, mocked_display, mocked_service_item) # THEN: it should return True - self.assertTrue(ret, '_check_file_type should return True when the players available are different' - 'from the processor from the service item.') + assert ret is True, '_check_file_type should return True when the players available are different' \ + 'from the processor from the service item.' def test_media_play_msg(self): """ === modified file 'tests/functional/openlp_core/ui/media/test_systemplayer.py' --- tests/functional/openlp_core/ui/media/test_systemplayer.py 2017-10-07 07:05:07 +0000 +++ tests/functional/openlp_core/ui/media/test_systemplayer.py 2017-12-20 21:28:03 +0000 @@ -64,17 +64,17 @@ player = SystemPlayer(self) # THEN: The correct initial values should be set up - self.assertEqual('system', player.name) - self.assertEqual('System', player.original_name) - self.assertEqual('&System', player.display_name) - self.assertEqual(self, player.parent) - self.assertEqual(ADDITIONAL_EXT, player.additional_extensions) + assert 'system' == player.name + assert 'System' == player.original_name + assert '&System' == player.display_name + assert self == player.parent + assert ADDITIONAL_EXT == player.additional_extensions MockQMediaPlayer.assert_called_once_with(None, QtMultimedia.QMediaPlayer.VideoSurface) mocked_mimetypes.init.assert_called_once_with() mocked_media_player.service.assert_called_once_with() mocked_media_player.supportedMimeTypes.assert_called_once_with() - self.assertEqual(['*.aiff'], player.audio_extensions_list) - self.assertEqual(['*.afl', '*.asf'], player.video_extensions_list) + assert ['*.aiff'] == player.audio_extensions_list + assert ['*.afl', '*.asf'] == player.video_extensions_list @patch('openlp.core.ui.media.systemplayer.QtMultimediaWidgets.QVideoWidget') @patch('openlp.core.ui.media.systemplayer.QtMultimedia.QMediaPlayer') @@ -96,15 +96,15 @@ # THEN: The player should have a display widget MockQVideoWidget.assert_called_once_with(mocked_display) - self.assertEqual(mocked_video_widget, mocked_display.video_widget) + assert mocked_video_widget, mocked_display.video_widget is True mocked_display.size.assert_called_once_with() mocked_video_widget.resize.assert_called_once_with([1, 2, 3, 4]) MockQMediaPlayer.assert_called_with(mocked_display) - self.assertEqual(mocked_media_player, mocked_display.media_player) + assert mocked_media_player, mocked_display.media_player is True mocked_media_player.setVideoOutput.assert_called_once_with(mocked_video_widget) mocked_video_widget.raise_.assert_called_once_with() mocked_video_widget.hide.assert_called_once_with() - self.assertTrue(player.has_own_widget) + assert player.has_own_widget is True def test_disconnect_slots(self): """ @@ -133,7 +133,7 @@ result = player.check_available() # THEN: it should be available - self.assertTrue(result) + assert result is True def test_load_valid_media(self): """ @@ -157,7 +157,7 @@ mocked_display.media_player.setMedia.assert_called_once_with( QtMultimedia.QMediaContent(QtCore.QUrl.fromLocalFile('/path/to/file'))) mocked_volume.assert_called_once_with(mocked_display, 1) - self.assertTrue(result) + assert result is True def test_load_invalid_media(self): """ @@ -178,7 +178,7 @@ # THEN: stuff mocked_display.controller.media_info.file_info.absoluteFilePath.assert_called_once_with() mocked_check_media.assert_called_once_with('/path/to/file') - self.assertFalse(result) + assert result is False def test_resize(self): """ @@ -227,7 +227,7 @@ mocked_display.media_player.durationChanged.connect.assert_called_once_with('function') mocked_set_state.assert_called_once_with(MediaState.Playing, mocked_display) mocked_display.video_widget.raise_.assert_called_once_with() - self.assertTrue(result) + assert result is True @patch('openlp.core.ui.media.systemplayer.functools') def test_play_is_preview(self, mocked_functools): @@ -258,7 +258,7 @@ mocked_display.media_player.durationChanged.connect.assert_called_once_with('function') mocked_set_state.assert_called_once_with(MediaState.Playing, mocked_display) mocked_display.video_widget.raise_.assert_called_once_with() - self.assertTrue(result) + assert result is True def test_pause_is_live(self): """ @@ -419,14 +419,13 @@ expected_position_calls = [call(), call()] expected_block_signals_calls = [call(True), call(False)] mocked_display.media_player.state.assert_called_once_with() - self.assertEqual(1, mocked_stop.call_count) - self.assertEqual(expected_stop_calls, mocked_stop.call_args_list) - self.assertEqual(2, mocked_display.media_player.position.call_count) - self.assertEqual(expected_position_calls, mocked_display.media_player.position.call_args_list) + assert 1 == mocked_stop.call_count + assert expected_stop_calls == mocked_stop.call_args_list + assert 2 == mocked_display.media_player.position.call_count + assert expected_position_calls == mocked_display.media_player.position.call_args_list mocked_set_visible.assert_called_once_with(mocked_display, False) mocked_display.controller.seek_slider.isSliderDown.assert_called_once_with() - self.assertEqual(expected_block_signals_calls, - mocked_display.controller.seek_slider.blockSignals.call_args_list) + assert expected_block_signals_calls == mocked_display.controller.seek_slider.blockSignals.call_args_list mocked_display.controller.seek_slider.setSliderPosition.assert_called_once_with(2) def test_get_media_display_css(self): @@ -440,7 +439,7 @@ result = player.get_media_display_css() # THEN: The css should be empty - self.assertEqual('', result) + assert '' == result @patch('openlp.core.ui.media.systemplayer.QtMultimedia.QMediaPlayer') def test_get_info(self, MockQMediaPlayer): @@ -459,7 +458,7 @@ # THEN: The info should be correct expected_info = 'This media player uses your operating system to provide media capabilities.<br/> ' \ '<strong>Audio</strong><br/>[]<br/><strong>Video</strong><br/>[]<br/>' - self.assertEqual(expected_info, result) + assert expected_info == result @patch('openlp.core.ui.media.systemplayer.CheckMediaWorker') @patch('openlp.core.ui.media.systemplayer.QtCore.QThread') @@ -493,9 +492,9 @@ mocked_check_media_worker.finished.connect.assert_called_once_with('quit') mocked_thread.started.connect.assert_called_once_with('play') mocked_thread.start.assert_called_once_with() - self.assertEqual(2, mocked_thread.isRunning.call_count) + assert 2 == mocked_thread.isRunning.call_count mocked_application.processEvents.assert_called_once_with() - self.assertTrue(result) + assert result is True class TestCheckMediaWorker(TestCase): @@ -513,7 +512,7 @@ worker = CheckMediaWorker(path) # THEN: The correct values should be set up - self.assertIsNotNone(worker) + assert worker is not None def test_signals_media(self): """ @@ -530,7 +529,7 @@ # THEN: The worker should exit and the result should be True mocked_stop.assert_called_once_with() mocked_finished.emit.assert_called_once_with() - self.assertTrue(worker.result) + assert worker.result is True def test_signals_error(self): """ @@ -547,4 +546,4 @@ # THEN: The worker should exit and the result should be True mocked_stop.assert_called_once_with() mocked_finished.emit.assert_called_once_with() - self.assertFalse(worker.result) + assert worker.result is False === modified file 'tests/functional/openlp_core/ui/media/test_vlcplayer.py' --- tests/functional/openlp_core/ui/media/test_vlcplayer.py 2017-12-04 20:32:02 +0000 +++ tests/functional/openlp_core/ui/media/test_vlcplayer.py 2017-12-20 21:28:03 +0000 @@ -24,7 +24,7 @@ """ import os import sys -from datetime import datetime, timedelta +from datetime import timedelta from unittest import TestCase, skip from unittest.mock import MagicMock, patch, call @@ -64,7 +64,7 @@ get_vlc() # THEN: The extra environment variable should be there - self.assertNotIn('openlp.core.ui.media.vendor.vlc', sys.modules) + assert 'openlp.core.ui.media.vendor.vlc' not in sys.modules @patch('openlp.core.ui.media.vlcplayer.is_macosx') def test_fix_vlc_22_plugin_path(self, mocked_is_macosx): @@ -78,9 +78,8 @@ get_vlc() # THEN: The extra environment variable should be there - self.assertIn('VLC_PLUGIN_PATH', os.environ, - 'The plugin path should be in the environment variables') - self.assertEqual('/Applications/VLC.app/Contents/MacOS/plugins', os.environ['VLC_PLUGIN_PATH']) + assert 'VLC_PLUGIN_PATH' in os.environ, 'The plugin path should be in the environment variables' + assert '/Applications/VLC.app/Contents/MacOS/plugins' == os.environ['VLC_PLUGIN_PATH'] @patch.dict(os.environ) @patch('openlp.core.ui.media.vlcplayer.is_macosx') @@ -95,8 +94,7 @@ get_vlc() # THEN: The extra environment variable should NOT be there - self.assertNotIn('VLC_PLUGIN_PATH', os.environ, - 'The plugin path should NOT be in the environment variables') + assert 'VLC_PLUGIN_PATH'not in os.environ, 'The plugin path should NOT be in the environment variables' def test_init(self): """ @@ -109,12 +107,12 @@ vlc_player = VlcPlayer(None) # THEN: The correct variables are set - self.assertEqual('VLC', vlc_player.original_name) - self.assertEqual('&VLC', vlc_player.display_name) - self.assertIsNone(vlc_player.parent) - self.assertTrue(vlc_player.can_folder) - self.assertListEqual(AUDIO_EXT, vlc_player.audio_extensions_list) - self.assertListEqual(VIDEO_EXT, vlc_player.video_extensions_list) + assert 'VLC' == vlc_player.original_name + assert '&VLC' == vlc_player.display_name + assert vlc_player.parent is None + assert vlc_player.can_folder is True + assert AUDIO_EXT == vlc_player.audio_extensions_list + assert VIDEO_EXT == vlc_player.video_extensions_list @patch('openlp.core.ui.media.vlcplayer.is_win') @patch('openlp.core.ui.media.vlcplayer.is_macosx') @@ -151,20 +149,20 @@ vlc_player.setup(mocked_display) # THEN: The VLC widget should be set up correctly - self.assertEqual(mocked_display.vlc_widget, mocked_qframe) + assert mocked_display.vlc_widget == mocked_qframe mocked_qframe.setFrameStyle.assert_called_with(1) mocked_settings.value.assert_called_with('advanced/hide mouse') mocked_vlc.Instance.assert_called_with('--no-video-title-show --no-audio --no-video-title-show ' '--mouse-hide-timeout=0') - self.assertEqual(mocked_display.vlc_instance, mocked_instance) + assert mocked_display.vlc_instance == mocked_instance mocked_instance.media_player_new.assert_called_with() - self.assertEqual(mocked_display.vlc_media_player, mocked_media_player_new) + assert mocked_display.vlc_media_player == mocked_media_player_new mocked_display.size.assert_called_with() mocked_qframe.resize.assert_called_with((10, 10)) mocked_qframe.raise_.assert_called_with() mocked_qframe.hide.assert_called_with() mocked_media_player_new.set_xwindow.assert_called_with(2) - self.assertTrue(vlc_player.has_own_widget) + assert vlc_player.has_own_widget is True @patch('openlp.core.ui.media.vlcplayer.is_win') @patch('openlp.core.ui.media.vlcplayer.is_macosx') @@ -328,7 +326,7 @@ is_available = vlc_player.check_available() # THEN: VLC should be available - self.assertTrue(is_available) + assert is_available is True @patch('openlp.core.ui.media.vlcplayer.get_vlc') def test_check_not_available(self, mocked_get_vlc): @@ -343,7 +341,7 @@ is_available = vlc_player.check_available() # THEN: VLC should NOT be available - self.assertFalse(is_available) + assert is_available is False @patch('openlp.core.ui.media.vlcplayer.get_vlc') @patch('openlp.core.ui.media.vlcplayer.os.path.normcase') @@ -376,11 +374,11 @@ # THEN: The video should be loaded mocked_normcase.assert_called_with(media_path) mocked_display.vlc_instance.media_new_path.assert_called_with(media_path) - self.assertEqual(mocked_vlc_media, mocked_display.vlc_media) + assert mocked_vlc_media == mocked_display.vlc_media mocked_display.vlc_media_player.set_media.assert_called_with(mocked_vlc_media) mocked_vlc_media.parse.assert_called_with() mocked_volume.assert_called_with(mocked_display, 100) - self.assertTrue(result) + assert result is True @patch('openlp.core.ui.media.vlcplayer.is_win') @patch('openlp.core.ui.media.vlcplayer.get_vlc') @@ -421,11 +419,11 @@ # THEN: The video should be loaded mocked_normcase.assert_called_with(media_path) mocked_display.vlc_instance.media_new_location.assert_called_with('cdda://' + media_path) - self.assertEqual(mocked_vlc_media, mocked_display.vlc_media) + assert mocked_vlc_media == mocked_display.vlc_media mocked_display.vlc_media_player.set_media.assert_called_with(mocked_vlc_media) mocked_vlc_media.parse.assert_called_with() mocked_volume.assert_called_with(mocked_display, 100) - self.assertTrue(result) + assert result is True @patch('openlp.core.ui.media.vlcplayer.is_win') @patch('openlp.core.ui.media.vlcplayer.get_vlc') @@ -466,11 +464,11 @@ # THEN: The video should be loaded mocked_normcase.assert_called_with(media_path) mocked_display.vlc_instance.media_new_location.assert_called_with('cdda:///' + media_path) - self.assertEqual(mocked_vlc_media, mocked_display.vlc_media) + assert mocked_vlc_media == mocked_display.vlc_media mocked_display.vlc_media_player.set_media.assert_called_with(mocked_vlc_media) mocked_vlc_media.parse.assert_called_with() mocked_volume.assert_called_with(mocked_display, 100) - self.assertTrue(result) + assert result is True @patch('openlp.core.ui.media.vlcplayer.is_win') @patch('openlp.core.ui.media.vlcplayer.get_vlc') @@ -511,11 +509,11 @@ # THEN: The video should be loaded mocked_normcase.assert_called_with(media_path) mocked_display.vlc_instance.media_new_location.assert_called_with('cdda://' + media_path) - self.assertEqual(mocked_vlc_media, mocked_display.vlc_media) - self.assertEqual(0, mocked_subitems.item_at_index.call_count) + assert mocked_vlc_media == mocked_display.vlc_media + assert 0 == mocked_subitems.item_at_index.call_count mocked_display.vlc_media_player.set_media.assert_called_with(mocked_vlc_media) - self.assertEqual(0, mocked_vlc_media.parse.call_count) - self.assertFalse(result) + assert 0 == mocked_vlc_media.parse.call_count + assert result is False @patch('openlp.core.ui.media.vlcplayer.get_vlc') @patch('openlp.core.ui.media.vlcplayer.datetime', MockDateTime) @@ -538,7 +536,7 @@ result = vlc_player.media_state_wait(mocked_display, 2) # THEN: The results should be True - self.assertTrue(result) + assert result is True @patch('openlp.core.ui.media.vlcplayer.get_vlc') @patch('openlp.core.ui.media.vlcplayer.datetime', MockDateTime) @@ -561,7 +559,7 @@ result = vlc_player.media_state_wait(mocked_display, 2) # THEN: The results should be True - self.assertFalse(result) + assert result is False @patch('openlp.core.ui.media.vlcplayer.get_vlc') @patch('openlp.core.ui.media.vlcplayer.datetime', MockDateTime) @@ -586,7 +584,7 @@ result = vlc_player.media_state_wait(mocked_display, 3) # THEN: The results should be True - self.assertFalse(result) + assert result is False def test_resize(self): """ @@ -636,9 +634,9 @@ # THEN: A bunch of things should happen to play the media mocked_thread.start.assert_called_with() mocked_volume.assert_called_with(mocked_display, 100) - self.assertEqual(MediaState.Playing, vlc_player.get_live_state()) + assert MediaState.Playing == vlc_player.get_live_state() mocked_display.vlc_widget.raise_.assert_called_with() - self.assertTrue(result, 'The value returned from play() should be True') + assert result is True, 'The value returned from play() should be True' @patch('openlp.core.ui.media.vlcplayer.threading') @patch('openlp.core.ui.media.vlcplayer.get_vlc') @@ -666,7 +664,7 @@ # THEN: A thread should be started, but the method should return False mocked_thread.start.assert_called_with() - self.assertFalse(result) + assert result is False @patch('openlp.core.ui.media.vlcplayer.threading') @patch('openlp.core.ui.media.vlcplayer.get_vlc') @@ -705,9 +703,9 @@ mocked_display.vlc_media_player.audio_set_track.assert_called_with(1) mocked_display.vlc_media_player.video_set_spu.assert_called_with(1) mocked_volume.assert_called_with(mocked_display, 100) - self.assertEqual(MediaState.Playing, vlc_player.get_live_state()) + assert MediaState.Playing == vlc_player.get_live_state() mocked_display.vlc_widget.raise_.assert_called_with() - self.assertTrue(result, 'The value returned from play() should be True') + assert result is True, 'The value returned from play() should be True' @patch('openlp.core.ui.media.vlcplayer.get_vlc') def test_pause(self, mocked_get_vlc): @@ -732,7 +730,7 @@ mocked_display.vlc_media.get_state.assert_called_with() mocked_display.vlc_media_player.pause.assert_called_with() mocked_media_state_wait.assert_called_with(mocked_display, 2) - self.assertEqual(MediaState.Paused, vlc_player.get_live_state()) + assert MediaState.Paused == vlc_player.get_live_state() @patch('openlp.core.ui.media.vlcplayer.get_vlc') def test_pause_not_playing(self, mocked_get_vlc): @@ -752,7 +750,7 @@ # THEN: The pause method should exit early mocked_display.vlc_media.get_state.assert_called_with() - self.assertEqual(0, mocked_display.vlc_media_player.pause.call_count) + assert 0 == mocked_display.vlc_media_player.pause.call_count @patch('openlp.core.ui.media.vlcplayer.get_vlc') def test_pause_fail(self, mocked_get_vlc): @@ -777,7 +775,7 @@ mocked_display.vlc_media.get_state.assert_called_with() mocked_display.vlc_media_player.pause.assert_called_with() mocked_media_state_wait.assert_called_with(mocked_display, 2) - self.assertNotEqual(MediaState.Paused, vlc_player.state) + assert MediaState.Paused is not vlc_player.state @patch('openlp.core.ui.media.vlcplayer.threading') def test_stop(self, mocked_threading): @@ -798,7 +796,7 @@ # THEN: A thread should have been started to stop VLC mocked_threading.Thread.assert_called_with(target=mocked_stop) mocked_thread.start.assert_called_with() - self.assertEqual(MediaState.Stopped, vlc_player.get_live_state()) + assert MediaState.Stopped == vlc_player.get_live_state() def test_volume(self): """ @@ -828,7 +826,7 @@ vlc_player.volume(mocked_display, 10) # THEN: The volume should NOT have been set - self.assertEqual(0, mocked_display.vlc_media_player.audio_set_volume.call_count) + assert 0 == mocked_display.vlc_media_player.audio_set_volume.call_count def test_seek_unseekable_media(self): """ @@ -845,7 +843,7 @@ # THEN: nothing should happen mocked_display.vlc_media_player.is_seekable.assert_called_with() - self.assertEqual(0, mocked_display.vlc_media_player.set_time.call_count) + assert 0 == mocked_display.vlc_media_player.set_time.call_count def test_seek_seekable_media(self): """ @@ -896,7 +894,7 @@ # THEN: The media should be stopped and invisible mocked_display.vlc_media_player.stop.assert_called_with() mocked_display.vlc_widget.setVisible.assert_called_with(False) - self.assertEqual(MediaState.Off, vlc_player.get_live_state()) + assert MediaState.Off == vlc_player.get_live_state() def test_set_visible_has_own_widget(self): """ @@ -926,7 +924,7 @@ vlc_player.set_visible(mocked_display, True) # THEN: The media should be stopped and invsibile - self.assertEqual(0, mocked_display.vlc_widget.setVisible.call_count) + assert 0 == mocked_display.vlc_widget.setVisible.call_count @patch('openlp.core.ui.media.vlcplayer.get_vlc') def test_update_ui(self, mocked_get_vlc): @@ -953,12 +951,12 @@ # THEN: Certain methods should be called mocked_stop.assert_called_with(mocked_display) - self.assertEqual(2, mocked_stop.call_count) + assert 2, mocked_stop.call_count mocked_display.vlc_media_player.get_time.assert_called_with() mocked_set_visible.assert_called_with(mocked_display, False) mocked_controller.seek_slider.setSliderPosition.assert_called_with(400000) expected_calls = [call(True), call(False)] - self.assertEqual(expected_calls, mocked_controller.seek_slider.blockSignals.call_args_list) + assert expected_calls == mocked_controller.seek_slider.blockSignals.call_args_list @patch('openlp.core.ui.media.vlcplayer.get_vlc') def test_update_ui_dvd(self, mocked_get_vlc): @@ -987,12 +985,12 @@ # THEN: Certain methods should be called mocked_stop.assert_called_with(mocked_display) - self.assertEqual(2, mocked_stop.call_count) + assert 2, mocked_stop.call_count mocked_display.vlc_media_player.get_time.assert_called_with() mocked_set_visible.assert_called_with(mocked_display, False) mocked_controller.seek_slider.setSliderPosition.assert_called_with(300) expected_calls = [call(True), call(False)] - self.assertEqual(expected_calls, mocked_controller.seek_slider.blockSignals.call_args_list) + assert expected_calls == mocked_controller.seek_slider.blockSignals.call_args_list @patch('openlp.core.ui.media.vlcplayer.translate') def test_get_info(self, mocked_translate): @@ -1007,6 +1005,6 @@ info = vlc_player.get_info() # THEN: The information should be correct - self.assertEqual('VLC is an external player which supports a number of different formats.<br/> ' - '<strong>Audio</strong><br/>' + str(AUDIO_EXT) + '<br/><strong>Video</strong><br/>' + - str(VIDEO_EXT) + '<br/>', info) + assert 'VLC is an external player which supports a number of different formats.<br/> ' \ + '<strong>Audio</strong><br/>' + str(AUDIO_EXT) + '<br/><strong>Video</strong><br/>' + \ + str(VIDEO_EXT) + '<br/>' == info === modified file 'tests/functional/openlp_core/ui/media/test_webkitplayer.py' --- tests/functional/openlp_core/ui/media/test_webkitplayer.py 2017-04-24 05:17:55 +0000 +++ tests/functional/openlp_core/ui/media/test_webkitplayer.py 2017-12-20 21:28:03 +0000 @@ -47,8 +47,7 @@ available = webkit_player.check_available() # THEN: The player should not be available when '[object HTMLUnknownElement]' is returned - self.assertEqual(False, available, - 'The WebkitPlayer should not be available when video feature detection fails') + assert available is False, 'The WebkitPlayer should not be available when video feature detection fails' def test_check_available_video_enabled(self): """ @@ -64,5 +63,4 @@ available = webkit_player.check_available() # THEN: The player should be available when '[object HTMLVideoElement]' is returned - self.assertEqual(True, available, - 'The WebkitPlayer should be available when video feature detection passes') + assert available is True, 'The WebkitPlayer should be available when video feature detection passes' === modified file 'tests/functional/openlp_core/ui/test_aboutform.py' --- tests/functional/openlp_core/ui/test_aboutform.py 2017-10-29 06:01:25 +0000 +++ tests/functional/openlp_core/ui/test_aboutform.py 2017-12-20 21:28:03 +0000 @@ -59,8 +59,8 @@ about_form = AboutForm(None) # THEN: The build number should be in the text - self.assertTrue('OpenLP 3.1.5 build 3000' in about_form.about_text_edit.toPlainText(), - "The build number should be set correctly") + assert 'OpenLP 3.1.5 build 3000' in about_form.about_text_edit.toPlainText(), \ + "The build number should be set correctly" def test_about_form_date(self): """ @@ -74,5 +74,4 @@ license_text = about_form.license_text_edit.toPlainText() # THEN: The date should be in the text twice. - self.assertTrue(license_text.count(date_string, 0) == 2, - "The text string should be added twice to the license string") + assert license_text.count(date_string, 0) == 2, "The text string should be added twice to the license string" === modified file 'tests/functional/openlp_core/ui/test_advancedtab.py' --- tests/functional/openlp_core/ui/test_advancedtab.py 2017-10-07 07:05:07 +0000 +++ tests/functional/openlp_core/ui/test_advancedtab.py 2017-12-20 21:28:03 +0000 @@ -50,7 +50,7 @@ advanced_tab = AdvancedTab(settings_form) # THEN: - self.assertEqual("Advanced", advanced_tab.tab_title, 'The tab title should be Advanced') + assert "Advanced" == advanced_tab.tab_title, 'The tab title should be Advanced' def test_change_search_as_type(self): """ @@ -64,6 +64,6 @@ advanced_tab.on_search_as_type_check_box_changed(True) # THEN: we should have two post save processed to run - self.assertEqual(2, len(settings_form.processes), 'Two post save processes should be created') - self.assertTrue("songs_config_updated" in settings_form.processes, 'The songs plugin should be called') - self.assertTrue("custom_config_updated" in settings_form.processes, 'The custom plugin should be called') + assert 2 == len(settings_form.processes), 'Two post save processes should be created' + assert "songs_config_updated" in settings_form.processes, 'The songs plugin should be called' + assert "custom_config_updated" in settings_form.processes, 'The custom plugin should be called' === modified file 'tests/functional/openlp_core/ui/test_firsttimeform.py' --- tests/functional/openlp_core/ui/test_firsttimeform.py 2017-10-07 07:05:07 +0000 +++ tests/functional/openlp_core/ui/test_firsttimeform.py 2017-12-20 21:28:03 +0000 @@ -90,12 +90,12 @@ frw.initialize(expected_screens) # THEN: The screens should be set up, and the default values initialised - self.assertEqual(expected_screens, frw.screens, 'The screens should be correct') - self.assertTrue(frw.web_access, 'The default value of self.web_access should be True') - self.assertFalse(frw.was_cancelled, 'The default value of self.was_cancelled should be False') - self.assertListEqual([], frw.theme_screenshot_threads, 'The list of threads should be empty') - self.assertListEqual([], frw.theme_screenshot_workers, 'The list of workers should be empty') - self.assertFalse(frw.has_run_wizard, 'has_run_wizard should be False') + assert expected_screens == frw.screens, 'The screens should be correct' + assert frw.web_access is True, 'The default value of self.web_access should be True' + assert frw.was_cancelled is False, 'The default value of self.was_cancelled should be False' + assert [] == frw.theme_screenshot_threads, 'The list of threads should be empty' + assert [] == frw.theme_screenshot_workers, 'The list of workers should be empty' + assert frw.has_run_wizard is False, 'has_run_wizard should be False' def test_set_defaults(self): """ @@ -124,7 +124,7 @@ # THEN: The default values should have been set mocked_restart.assert_called_with() - self.assertEqual('http://openlp.org/files/frw/', frw.web, 'The default URL should be set') + assert 'http://openlp.org/files/frw/' == frw.web, 'The default URL should be set' mocked_cancel_button.clicked.connect.assert_called_with(frw.on_cancel_button_clicked) mocked_no_internet_finish_btn.clicked.connect.assert_called_with(frw.on_no_internet_finish_button_clicked) mocked_currentIdChanged.connect.assert_called_with(frw.on_current_id_changed) @@ -176,12 +176,12 @@ frw.on_cancel_button_clicked() # THEN: The right things should be called in the right order - self.assertTrue(frw.was_cancelled, 'The was_cancelled property should have been set to True') + assert frw.was_cancelled is True, 'The was_cancelled property should have been set to True' mocked_worker.set_download_canceled.assert_called_with(True) mocked_thread.isRunning.assert_called_with() - self.assertEqual(2, mocked_thread.isRunning.call_count, 'isRunning() should have been called twice') + assert 2 == mocked_thread.isRunning.call_count, 'isRunning() should have been called twice' mocked_time.sleep.assert_called_with(0.1) - self.assertEqual(1, mocked_time.sleep.call_count, 'sleep() should have only been called once') + assert 1 == mocked_time.sleep.call_count, 'sleep() should have only been called once' mocked_set_normal_cursor.assert_called_with() def test_broken_config(self): @@ -198,7 +198,7 @@ first_time_form._download_index() # THEN: The First Time Form should not have web access - self.assertFalse(first_time_form.web_access, 'There should not be web access with a broken config file') + assert first_time_form.web_access is False, 'There should not be web access with a broken config file' def test_invalid_config(self): """ @@ -214,7 +214,7 @@ first_time_form._download_index() # THEN: The First Time Form should not have web access - self.assertFalse(first_time_form.web_access, 'There should not be web access with an invalid config file') + assert first_time_form.web_access is False, 'There should not be web access with an invalid config file' @patch('openlp.core.ui.firsttimeform.get_web_page') @patch('openlp.core.ui.firsttimeform.QtWidgets.QMessageBox') === modified file 'tests/functional/openlp_core/ui/test_formattingtagscontroller.py' --- tests/functional/openlp_core/ui/test_formattingtagscontroller.py 2016-12-31 11:01:36 +0000 +++ tests/functional/openlp_core/ui/test_formattingtagscontroller.py 2017-12-20 21:28:03 +0000 @@ -43,7 +43,7 @@ result = self.services._strip(tag) # THEN: The tag should be returned with the wrappers removed. - self.assertEqual(result, 'tag', 'FormattingTagForm._strip should return u\'tag\' when called with u\'{tag}\'') + assert result == 'tag', 'FormattingTagForm._strip should return u\'tag\' when called with u\'{tag}\'' def test_end_tag_changed_processes_correctly(self): """ @@ -64,11 +64,9 @@ error, result = self.services.end_tag_changed(test['start'], test['end']) # THEN: The result should match the predetermined value. - self.assertTrue(result == test['gen'], - 'Function should handle end tag correctly : %s and %s for %s ' % - (test['gen'], result, test['start'])) - self.assertTrue(error == test['valid'], 'Function should not generate unexpected error messages : %s ' % - error) + assert result == test['gen'], \ + 'Function should handle end tag correctly : %s and %s for %s ' % (test['gen'], result, test['start']) + assert error == test['valid'], 'Function should not generate unexpected error messages : %s ' % error def test_start_tag_changed_processes_correctly(self): """ @@ -88,10 +86,9 @@ error, result = self.services.start_tag_changed(test['start'], test['end']) # THEN: The result should match the predetermined value. - self.assertTrue(result == test['gen'], 'Function should handle end tag correctly : %s and %s ' % - (test['gen'], result)) - self.assertTrue(error == test['valid'], 'Function should not generate unexpected error messages : %s ' % - error) + assert result == test['gen'], \ + 'Function should handle end tag correctly : %s and %s ' % (test['gen'], result) + assert error == test['valid'], 'Function should not generate unexpected error messages : %s ' % error def test_start_html_to_end_html(self): """ @@ -106,5 +103,4 @@ result = self.services.start_html_to_end_html(test1) # THEN: The result should match the predetermined value. - self.assertTrue(result == test2, 'Calculated end tag should be valid: %s and %s = %s' % - (test1, test2, result)) + assert result == test2, 'Calculated end tag should be valid: %s and %s = %s' % (test1, test2, result) === modified file 'tests/functional/openlp_core/ui/test_formattingtagsform.py' --- tests/functional/openlp_core/ui/test_formattingtagsform.py 2017-05-30 18:42:35 +0000 +++ tests/functional/openlp_core/ui/test_formattingtagsform.py 2017-12-20 21:28:03 +0000 @@ -83,8 +83,8 @@ call(row_count, 2, mocked_table_widget), call(row_count, 3, mocked_table_widget) ] - self.assertEqual(expected_set_item_calls, form.tag_table_widget.setItem.call_args_list, - 'setItem should have been called correctly') + assert expected_set_item_calls == form.tag_table_widget.setItem.call_args_list, \ + 'setItem should have been called correctly' form.tag_table_widget.resizeRowsToContents.assert_called_with() form.tag_table_widget.scrollToBottom.assert_called_with() form.tag_table_widget.selectRow.assert_called_with(row_count) === modified file 'tests/functional/openlp_core/ui/test_maindisplay.py' --- tests/functional/openlp_core/ui/test_maindisplay.py 2017-10-10 07:08:44 +0000 +++ tests/functional/openlp_core/ui/test_maindisplay.py 2017-12-20 21:28:03 +0000 @@ -83,7 +83,7 @@ main_display = MainDisplay(display) # THEN: The controller should be a live controller. - self.assertEqual(main_display.is_live, True, 'The main display should be a live controller') + assert main_display.is_live is True, 'The main display should be a live controller' def test_set_transparency_enabled(self): """ @@ -97,12 +97,12 @@ main_display.set_transparency(True) # THEN: The transparent stylesheet should be used - self.assertEqual(TRANSPARENT_STYLESHEET, main_display.styleSheet(), - 'The MainDisplay should use the transparent stylesheet') - self.assertFalse(main_display.autoFillBackground(), - 'The MainDisplay should not have autoFillBackground set') - self.assertTrue(main_display.testAttribute(QtCore.Qt.WA_TranslucentBackground), - 'The MainDisplay should have a translucent background') + assert TRANSPARENT_STYLESHEET == main_display.styleSheet(), \ + 'The MainDisplay should use the transparent stylesheet' + assert main_display.autoFillBackground() is False, \ + 'The MainDisplay should not have autoFillBackground set' + assert main_display.testAttribute(QtCore.Qt.WA_TranslucentBackground) is True, \ + 'The MainDisplay should have a translucent background' def test_set_transparency_disabled(self): """ @@ -116,10 +116,10 @@ main_display.set_transparency(False) # THEN: The opaque stylesheet should be used - self.assertEqual(OPAQUE_STYLESHEET, main_display.styleSheet(), - 'The MainDisplay should use the opaque stylesheet') - self.assertFalse(main_display.testAttribute(QtCore.Qt.WA_TranslucentBackground), - 'The MainDisplay should not have a translucent background') + assert OPAQUE_STYLESHEET == main_display.styleSheet(), \ + 'The MainDisplay should use the opaque stylesheet' + assert main_display.testAttribute(QtCore.Qt.WA_TranslucentBackground) is False, \ + 'The MainDisplay should not have a translucent background' def test_css_changed(self): """ @@ -156,9 +156,9 @@ main_display = MainDisplay(display) # THEN: The window flags should be the same as those needed on Mac OS X. - self.assertEqual(QtCore.Qt.Window | QtCore.Qt.FramelessWindowHint | QtCore.Qt.NoDropShadowWindowHint, - main_display.windowFlags(), - 'The window flags should be Qt.Window, Qt.FramelessWindowHint, and Qt.NoDropShadowWindowHint.') + assert QtCore.Qt.Window | QtCore.Qt.FramelessWindowHint | QtCore.Qt.NoDropShadowWindowHint == \ + main_display.windowFlags(), \ + 'The window flags should be Qt.Window, Qt.FramelessWindowHint, and Qt.NoDropShadowWindowHint.' @skipUnless(is_macosx(), 'Can only run test on Mac OS X due to pyobjc dependency.') def test_macosx_display(self): @@ -181,10 +181,10 @@ pyobjc_nsview = objc_object(cobject=nsview_pointer) # THEN: The window level and collection behavior should be the same as those needed for Mac OS X. - self.assertEqual(pyobjc_nsview.window().level(), NSMainMenuWindowLevel + 2, - 'Window level should be NSMainMenuWindowLevel + 2') - self.assertEqual(pyobjc_nsview.window().collectionBehavior(), NSWindowCollectionBehaviorManaged, - 'Window collection behavior should be NSWindowCollectionBehaviorManaged') + assert pyobjc_nsview.window().level() == NSMainMenuWindowLevel + 2, \ + 'Window level should be NSMainMenuWindowLevel + 2' + assert pyobjc_nsview.window().collectionBehavior() == NSWindowCollectionBehaviorManaged, \ + 'Window collection behavior should be NSWindowCollectionBehaviorManaged' @patch('openlp.core.ui.maindisplay.Settings') def test_show_display_startup_logo(self, MockedSettings): @@ -250,9 +250,9 @@ main_display.build_html(service_item) # THEN: the following should had not been called - self.assertEquals(main_display.web_view.setHtml.call_count, 1, 'setHTML should be called once') - self.assertEquals(main_display.media_controller.video.call_count, 0, - 'Media Controller video should not have been called') + assert main_display.web_view.setHtml.call_count == 1, 'setHTML should be called once' + assert main_display.media_controller.video.call_count == 0, \ + 'Media Controller video should not have been called' @patch('openlp.core.ui.maindisplay.Settings') @patch('openlp.core.ui.maindisplay.build_html') @@ -282,9 +282,9 @@ main_display.build_html(service_item) # THEN: the following should had not been called - self.assertEquals(main_display.web_view.setHtml.call_count, 1, 'setHTML should be called once') - self.assertEquals(main_display.media_controller.video.call_count, 1, - 'Media Controller video should have been called once') + assert main_display.web_view.setHtml.call_count == 1, 'setHTML should be called once' + assert main_display.media_controller.video.call_count == 1, \ + 'Media Controller video should have been called once' def test_calling_next_item_in_playlist(): === modified file 'tests/functional/openlp_core/ui/test_mainwindow.py' --- tests/functional/openlp_core/ui/test_mainwindow.py 2017-12-15 16:19:42 +0000 +++ tests/functional/openlp_core/ui/test_mainwindow.py 2017-12-20 21:28:03 +0000 @@ -130,8 +130,8 @@ self.main_window.set_service_modified(True, 'test.osz') # THEN the main window's title should be set to the - self.assertEqual(self.main_window.windowTitle(), '%s - %s*' % (UiStrings().OpenLP, 'test.osz'), - 'The main window\'s title should be set to "<the contents of UiStrings().OpenLP> - test.osz*"') + assert self.main_window.windowTitle(), '%s - %s*' % (UiStrings().OpenLP, 'test.osz') == \ + 'The main window\'s title should be set to "<the contents of UiStrings().OpenLP> - test.osz*"' def test_set_service_unmodified(self): """ @@ -143,8 +143,8 @@ self.main_window.set_service_modified(False, 'test.osz') # THEN the main window's title should be set to the - self.assertEqual(self.main_window.windowTitle(), '%s - %s' % (UiStrings().OpenLP, 'test.osz'), - 'The main window\'s title should be set to "<the contents of UiStrings().OpenLP> - test.osz"') + assert self.main_window.windowTitle(), '%s - %s' % (UiStrings().OpenLP, 'test.osz') == \ + 'The main window\'s title should be set to "<the contents of UiStrings().OpenLP> - test.osz"' def test_mainwindow_configuration(self): """ === modified file 'tests/functional/openlp_core/ui/test_media.py' --- tests/functional/openlp_core/ui/test_media.py 2017-04-24 05:17:55 +0000 +++ tests/functional/openlp_core/ui/test_media.py 2017-12-20 21:28:03 +0000 @@ -52,8 +52,8 @@ used_players, overridden_player = get_media_players() # THEN: the used_players should be an empty list, and the overridden player should be an empty string - self.assertEqual([], used_players, 'Used players should be an empty list') - self.assertEqual('', overridden_player, 'Overridden player should be an empty string') + assert [] == used_players, 'Used players should be an empty list' + assert '' == overridden_player, 'Overridden player should be an empty string' def test_get_media_players_no_players(self): """ @@ -73,8 +73,8 @@ used_players, overridden_player = get_media_players() # THEN: the used_players should be an empty list, and the overridden player should be an empty string - self.assertEqual([], used_players, 'Used players should be an empty list') - self.assertEqual('auto', overridden_player, 'Overridden player should be "auto"') + assert [] == used_players, 'Used players should be an empty list' + assert 'auto' == overridden_player, 'Overridden player should be "auto"' def test_get_media_players_with_valid_list(self): """ @@ -94,8 +94,8 @@ used_players, overridden_player = get_media_players() # THEN: the used_players should be an empty list, and the overridden player should be an empty string - self.assertEqual(['vlc', 'webkit', 'system'], used_players, 'Used players should be correct') - self.assertEqual('', overridden_player, 'Overridden player should be an empty string') + assert ['vlc', 'webkit', 'system'] == used_players, 'Used players should be correct' + assert '' == overridden_player, 'Overridden player should be an empty string' def test_get_media_players_with_overridden_player(self): """ @@ -115,8 +115,8 @@ used_players, overridden_player = get_media_players() # THEN: the used_players should be an empty list, and the overridden player should be an empty string - self.assertEqual(['vlc', 'webkit', 'system'], used_players, 'Used players should be correct') - self.assertEqual('vlc,webkit,system', overridden_player, 'Overridden player should be a string of players') + assert ['vlc', 'webkit', 'system'] == used_players, 'Used players should be correct' + assert 'vlc,webkit,system' == overridden_player, 'Overridden player should be a string of players' def test_parse_optical_path_linux(self): """ @@ -138,13 +138,13 @@ (device_path, title_track, audio_track, subtitle_track, start, end, name) = parse_optical_path(path) # THEN: The return values should match the original values - self.assertEqual(org_title_track, title_track, 'Returned title_track should match the original') - self.assertEqual(org_audio_track, audio_track, 'Returned audio_track should match the original') - self.assertEqual(org_subtitle_track, subtitle_track, 'Returned subtitle_track should match the original') - self.assertEqual(org_start, start, 'Returned start should match the original') - self.assertEqual(org_end, end, 'Returned end should match the original') - self.assertEqual(org_name, name, 'Returned end should match the original') - self.assertEqual(org_device_path, device_path, 'Returned device_path should match the original') + assert org_title_track == title_track, 'Returned title_track should match the original' + assert org_audio_track == audio_track, 'Returned audio_track should match the original' + assert org_subtitle_track == subtitle_track, 'Returned subtitle_track should match the original' + assert org_start == start, 'Returned start should match the original' + assert org_end == end, 'Returned end should match the original' + assert org_name == name, 'Returned end should match the original' + assert org_device_path == device_path, 'Returned device_path should match the original' def test_parse_optical_path_win(self): """ @@ -166,10 +166,10 @@ (device_path, title_track, audio_track, subtitle_track, start, end, name) = parse_optical_path(path) # THEN: The return values should match the original values - self.assertEqual(org_title_track, title_track, 'Returned title_track should match the original') - self.assertEqual(org_audio_track, audio_track, 'Returned audio_track should match the original') - self.assertEqual(org_subtitle_track, subtitle_track, 'Returned subtitle_track should match the original') - self.assertEqual(org_start, start, 'Returned start should match the original') - self.assertEqual(org_end, end, 'Returned end should match the original') - self.assertEqual(org_name, name, 'Returned end should match the original') - self.assertEqual(org_device_path, device_path, 'Returned device_path should match the original') + assert org_title_track == title_track, 'Returned title_track should match the original' + assert org_audio_track == audio_track, 'Returned audio_track should match the original' + assert org_subtitle_track == subtitle_track, 'Returned subtitle_track should match the original' + assert org_start == start, 'Returned start should match the original' + assert org_end == end, 'Returned end should match the original' + assert org_name == name, 'Returned end should match the original' + assert org_device_path == device_path, 'Returned device_path should match the original' === modified file 'tests/functional/openlp_core/ui/test_servicemanager.py' --- tests/functional/openlp_core/ui/test_servicemanager.py 2017-11-18 23:14:28 +0000 +++ tests/functional/openlp_core/ui/test_servicemanager.py 2017-12-20 21:28:03 +0000 @@ -54,7 +54,7 @@ ServiceManager(None) # WHEN: the default service manager is built. # THEN: The the controller should be registered in the registry. - self.assertNotEqual(Registry().get('service_manager'), None, 'The base service manager should be registered') + assert Registry().get('service_manager') is not None, 'The base service manager should be registered' def test_create_basic_service(self): """ @@ -67,9 +67,9 @@ service_manager.service_theme = 'test_theme' service = service_manager.create_basic_service()[0] # THEN: The controller should be registered in the registry. - self.assertNotEqual(service, None, 'The base service should be created') - self.assertEqual(service['openlp_core']['service-theme'], 'test_theme', 'The test theme should be saved') - self.assertEqual(service['openlp_core']['lite-service'], False, 'The lite service should be saved') + assert service is not None, 'The base service should be created' + assert service['openlp_core']['service-theme'] == 'test_theme', 'The test theme should be saved' + assert service['openlp_core']['lite-service'] is False, 'The lite service should be saved' def test_supported_suffixes(self): """ @@ -81,9 +81,9 @@ service_manager.supported_suffixes('txt') service_manager.supported_suffixes(['pptx', 'ppt']) # THEN: The suffixes should be available to test. - self.assertEqual('txt' in service_manager.suffixes, True, 'The suffix txt should be in the list') - self.assertEqual('ppt' in service_manager.suffixes, True, 'The suffix ppt should be in the list') - self.assertEqual('pptx' in service_manager.suffixes, True, 'The suffix pptx should be in the list') + assert 'txt' in service_manager.suffixes, 'The suffix txt should be in the list' + assert 'ppt' in service_manager.suffixes, 'The suffix ppt should be in the list' + assert 'pptx' in service_manager.suffixes, 'The suffix pptx should be in the list' def test_build_context_menu(self): """ @@ -114,20 +114,20 @@ # WHEN I define a context menu service_manager.context_menu(1) # THEN the following calls should have occurred. - self.assertEqual(service_manager.edit_action.setVisible.call_count, 1, 'Should have been called once') - self.assertEqual(service_manager.rename_action.setVisible.call_count, 1, 'Should have been called once') - self.assertEqual(service_manager.create_custom_action.setVisible.call_count, 1, 'Should have been called once') - self.assertEqual(service_manager.maintain_action.setVisible.call_count, 1, 'Should have been called once') - self.assertEqual(service_manager.notes_action.setVisible.call_count, 1, 'Should have been called once') - self.assertEqual(service_manager.time_action.setVisible.call_count, 1, 'Should have been called once') - self.assertEqual(service_manager.auto_start_action.setVisible.call_count, 1, 'Should have been called once') - self.assertEqual(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 1, - 'Should have been called once') - self.assertEqual(service_manager.auto_play_slides_once.setChecked.call_count, 0, 'Should not be called') - self.assertEqual(service_manager.auto_play_slides_loop.setChecked.call_count, 0, 'Should not be called') - self.assertEqual(service_manager.timed_slide_interval.setChecked.call_count, 0, 'Should not be called') - self.assertEqual(service_manager.theme_menu.menuAction().setVisible.call_count, 1, - 'Should have been called once') + assert service_manager.edit_action.setVisible.call_count == 1, 'Should have been called once' + assert service_manager.rename_action.setVisible.call_count == 1, 'Should have been called once' + assert service_manager.create_custom_action.setVisible.call_count == 1, 'Should have been called once' + assert service_manager.maintain_action.setVisible.call_count == 1, 'Should have been called once' + assert service_manager.notes_action.setVisible.call_count == 1, 'Should have been called once' + assert service_manager.time_action.setVisible.call_count == 1, 'Should have been called once' + assert service_manager.auto_start_action.setVisible.call_count == 1, 'Should have been called once' + assert service_manager.auto_play_slides_menu.menuAction().setVisible.call_count == 1, \ + 'Should have been called once' + assert service_manager.auto_play_slides_once.setChecked.call_count == 0, 'Should not be called' + assert service_manager.auto_play_slides_loop.setChecked.call_count == 0, 'Should not be called' + assert service_manager.timed_slide_interval.setChecked.call_count == 0, 'Should not be called' + assert service_manager.theme_menu.menuAction().setVisible.call_count == 1, \ + 'Should have been called once' def test_build_song_context_menu(self): """ @@ -169,29 +169,29 @@ # WHEN I define a context menu service_manager.context_menu(1) # THEN the following calls should have occurred. - self.assertEqual(service_manager.edit_action.setVisible.call_count, 2, 'Should have be called twice') - self.assertEqual(service_manager.rename_action.setVisible.call_count, 1, 'Should have be called once') - self.assertEqual(service_manager.create_custom_action.setVisible.call_count, 1, 'Should have be called once') - self.assertEqual(service_manager.maintain_action.setVisible.call_count, 1, 'Should have be called once') - self.assertEqual(service_manager.notes_action.setVisible.call_count, 1, 'Should have be called once') - self.assertEqual(service_manager.time_action.setVisible.call_count, 1, 'Should have be called once') - self.assertEqual(service_manager.auto_start_action.setVisible.call_count, 1, 'Should have be called once') - self.assertEqual(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 1, - 'Should have be called once') - self.assertEqual(service_manager.auto_play_slides_once.setChecked.call_count, 0, 'Should not be called') - self.assertEqual(service_manager.auto_play_slides_loop.setChecked.call_count, 0, 'Should not be called') - self.assertEqual(service_manager.timed_slide_interval.setChecked.call_count, 0, 'Should not be called') - self.assertEqual(service_manager.theme_menu.menuAction().setVisible.call_count, 2, - 'Should have be called twice') + assert service_manager.edit_action.setVisible.call_count == 2, 'Should have be called twice' + assert service_manager.rename_action.setVisible.call_count == 1, 'Should have be called once' + assert service_manager.create_custom_action.setVisible.call_count == 1, 'Should have be called once' + assert service_manager.maintain_action.setVisible.call_count == 1, 'Should have be called once' + assert service_manager.notes_action.setVisible.call_count == 1, 'Should have be called once' + assert service_manager.time_action.setVisible.call_count == 1, 'Should have be called once' + assert service_manager.auto_start_action.setVisible.call_count == 1, 'Should have be called once' + assert service_manager.auto_play_slides_menu.menuAction().setVisible.call_count == 1, \ + 'Should have be called once' + assert service_manager.auto_play_slides_once.setChecked.call_count == 0, 'Should not be called' + assert service_manager.auto_play_slides_loop.setChecked.call_count == 0, 'Should not be called' + assert service_manager.timed_slide_interval.setChecked.call_count == 0, 'Should not be called' + assert service_manager.theme_menu.menuAction().setVisible.call_count == 2, \ + 'Should have be called twice' # THEN we add a 2nd display frame service_item._display_frames.append(MagicMock()) service_manager.context_menu(1) # THEN the following additional calls should have occurred. - self.assertEqual(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 2, - 'Should have be called twice') - self.assertEqual(service_manager.auto_play_slides_once.setChecked.call_count, 1, 'Should have be called once') - self.assertEqual(service_manager.auto_play_slides_loop.setChecked.call_count, 1, 'Should have be called once') - self.assertEqual(service_manager.timed_slide_interval.setChecked.call_count, 1, 'Should have be called once') + assert service_manager.auto_play_slides_menu.menuAction().setVisible.call_count == 2, \ + 'Should have be called twice' + assert service_manager.auto_play_slides_once.setChecked.call_count == 1, 'Should have be called once' + assert service_manager.auto_play_slides_loop.setChecked.call_count == 1, 'Should have be called once' + assert service_manager.timed_slide_interval.setChecked.call_count == 1, 'Should have be called once' def test_build_bible_context_menu(self): """ @@ -233,29 +233,29 @@ # WHEN I define a context menu service_manager.context_menu(1) # THEN the following calls should have occurred. - self.assertEqual(service_manager.edit_action.setVisible.call_count, 1, 'Should have be called once') - self.assertEqual(service_manager.rename_action.setVisible.call_count, 2, 'Should have be called twice') - self.assertEqual(service_manager.create_custom_action.setVisible.call_count, 1, 'Should have be called once') - self.assertEqual(service_manager.maintain_action.setVisible.call_count, 1, 'Should have be called once') - self.assertEqual(service_manager.notes_action.setVisible.call_count, 1, 'Should have be called once') - self.assertEqual(service_manager.time_action.setVisible.call_count, 1, 'Should have be called once') - self.assertEqual(service_manager.auto_start_action.setVisible.call_count, 1, 'Should have be called once') - self.assertEqual(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 1, - 'Should have be called once') - self.assertEqual(service_manager.auto_play_slides_once.setChecked.call_count, 0, 'Should not be called') - self.assertEqual(service_manager.auto_play_slides_loop.setChecked.call_count, 0, 'Should not be called') - self.assertEqual(service_manager.timed_slide_interval.setChecked.call_count, 0, 'Should not be called') - self.assertEqual(service_manager.theme_menu.menuAction().setVisible.call_count, 2, - 'Should have be called twice') + assert service_manager.edit_action.setVisible.call_count == 1, 'Should have be called once' + assert service_manager.rename_action.setVisible.call_count == 2, 'Should have be called twice' + assert service_manager.create_custom_action.setVisible.call_count == 1, 'Should have be called once' + assert service_manager.maintain_action.setVisible.call_count == 1, 'Should have be called once' + assert service_manager.notes_action.setVisible.call_count == 1, 'Should have be called once' + assert service_manager.time_action.setVisible.call_count == 1, 'Should have be called once' + assert service_manager.auto_start_action.setVisible.call_count == 1, 'Should have be called once' + assert service_manager.auto_play_slides_menu.menuAction().setVisible.call_count == 1, \ + 'Should have be called once' + assert service_manager.auto_play_slides_once.setChecked.call_count == 0, 'Should not be called' + assert service_manager.auto_play_slides_loop.setChecked.call_count == 0, 'Should not be called' + assert service_manager.timed_slide_interval.setChecked.call_count == 0, 'Should not be called' + assert service_manager.theme_menu.menuAction().setVisible.call_count == 2, \ + 'Should have be called twice' # THEN we add a 2nd display frame service_item._display_frames.append(MagicMock()) service_manager.context_menu(1) # THEN the following additional calls should have occurred. - self.assertEqual(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 2, - 'Should have be called twice') - self.assertEqual(service_manager.auto_play_slides_once.setChecked.call_count, 1, 'Should have be called once') - self.assertEqual(service_manager.auto_play_slides_loop.setChecked.call_count, 1, 'Should have be called once') - self.assertEqual(service_manager.timed_slide_interval.setChecked.call_count, 1, 'Should have be called once') + assert service_manager.auto_play_slides_menu.menuAction().setVisible.call_count == 2, \ + 'Should have be called twice' + assert service_manager.auto_play_slides_once.setChecked.call_count == 1, 'Should have be called once' + assert service_manager.auto_play_slides_loop.setChecked.call_count == 1, 'Should have be called once' + assert service_manager.timed_slide_interval.setChecked.call_count == 1, 'Should have be called once' def test_build_custom_context_menu(self): """ @@ -298,29 +298,29 @@ # WHEN I define a context menu service_manager.context_menu(1) # THEN the following calls should have occurred. - self.assertEqual(service_manager.edit_action.setVisible.call_count, 2, 'Should have be called twice') - self.assertEqual(service_manager.rename_action.setVisible.call_count, 1, 'Should have be called once') - self.assertEqual(service_manager.create_custom_action.setVisible.call_count, 1, 'Should have be called once') - self.assertEqual(service_manager.maintain_action.setVisible.call_count, 1, 'Should have be called once') - self.assertEqual(service_manager.notes_action.setVisible.call_count, 1, 'Should have be called once') - self.assertEqual(service_manager.time_action.setVisible.call_count, 1, 'Should have be called once') - self.assertEqual(service_manager.auto_start_action.setVisible.call_count, 1, 'Should have be called once') - self.assertEqual(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 1, - 'Should have be called once') - self.assertEqual(service_manager.auto_play_slides_once.setChecked.call_count, 0, 'Should not be called') - self.assertEqual(service_manager.auto_play_slides_loop.setChecked.call_count, 0, 'Should not be called') - self.assertEqual(service_manager.timed_slide_interval.setChecked.call_count, 0, 'Should not be called') - self.assertEqual(service_manager.theme_menu.menuAction().setVisible.call_count, 2, - 'Should have be called twice') + assert service_manager.edit_action.setVisible.call_count == 2, 'Should have be called twice' + assert service_manager.rename_action.setVisible.call_count == 1, 'Should have be called once' + assert service_manager.create_custom_action.setVisible.call_count == 1, 'Should have be called once' + assert service_manager.maintain_action.setVisible.call_count == 1, 'Should have be called once' + assert service_manager.notes_action.setVisible.call_count == 1, 'Should have be called once' + assert service_manager.time_action.setVisible.call_count == 1, 'Should have be called once' + assert service_manager.auto_start_action.setVisible.call_count == 1, 'Should have be called once' + assert service_manager.auto_play_slides_menu.menuAction().setVisible.call_count == 1, \ + 'Should have be called once' + assert service_manager.auto_play_slides_once.setChecked.call_count == 0, 'Should not be called' + assert service_manager.auto_play_slides_loop.setChecked.call_count == 0, 'Should not be called' + assert service_manager.timed_slide_interval.setChecked.call_count == 0, 'Should not be called' + assert service_manager.theme_menu.menuAction().setVisible.call_count == 2, \ + 'Should have be called twice' # THEN we add a 2nd display frame service_item._display_frames.append(MagicMock()) service_manager.context_menu(1) # THEN the following additional calls should have occurred. - self.assertEqual(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 2, - 'Should have be called twice') - self.assertEqual(service_manager.auto_play_slides_once.setChecked.call_count, 1, 'Should have be called once') - self.assertEqual(service_manager.auto_play_slides_loop.setChecked.call_count, 1, 'Should have be called once') - self.assertEqual(service_manager.timed_slide_interval.setChecked.call_count, 1, 'Should have be called once') + assert service_manager.auto_play_slides_menu.menuAction().setVisible.call_count == 2, \ + 'Should have be called twice' + assert service_manager.auto_play_slides_once.setChecked.call_count == 1, 'Should have be called once' + assert service_manager.auto_play_slides_loop.setChecked.call_count == 1, 'Should have be called once' + assert service_manager.timed_slide_interval.setChecked.call_count == 1, 'Should have be called once' def test_build_image_context_menu(self): """ @@ -361,29 +361,29 @@ # WHEN I define a context menu service_manager.context_menu(1) # THEN the following calls should have occurred. - self.assertEqual(service_manager.edit_action.setVisible.call_count, 1, 'Should have be called once') - self.assertEqual(service_manager.rename_action.setVisible.call_count, 2, 'Should have be called twice') - self.assertEqual(service_manager.create_custom_action.setVisible.call_count, 1, 'Should have be called once') - self.assertEqual(service_manager.maintain_action.setVisible.call_count, 2, 'Should have be called twice') - self.assertEqual(service_manager.notes_action.setVisible.call_count, 1, 'Should have be called once') - self.assertEqual(service_manager.time_action.setVisible.call_count, 1, 'Should have be called once') - self.assertEqual(service_manager.auto_start_action.setVisible.call_count, 1, 'Should have be called once') - self.assertEqual(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 1, - 'Should have be called once') - self.assertEqual(service_manager.auto_play_slides_once.setChecked.call_count, 0, 'Should not be called') - self.assertEqual(service_manager.auto_play_slides_loop.setChecked.call_count, 0, 'Should not be called') - self.assertEqual(service_manager.timed_slide_interval.setChecked.call_count, 0, 'Should not be called') - self.assertEqual(service_manager.theme_menu.menuAction().setVisible.call_count, 1, - 'Should have be called once') + assert service_manager.edit_action.setVisible.call_count == 1, 'Should have be called once' + assert service_manager.rename_action.setVisible.call_count == 2, 'Should have be called twice' + assert service_manager.create_custom_action.setVisible.call_count == 1, 'Should have be called once' + assert service_manager.maintain_action.setVisible.call_count == 2, 'Should have be called twice' + assert service_manager.notes_action.setVisible.call_count == 1, 'Should have be called once' + assert service_manager.time_action.setVisible.call_count == 1, 'Should have be called once' + assert service_manager.auto_start_action.setVisible.call_count == 1, 'Should have be called once' + assert service_manager.auto_play_slides_menu.menuAction().setVisible.call_count == 1, \ + 'Should have be called once' + assert service_manager.auto_play_slides_once.setChecked.call_count == 0, 'Should not be called' + assert service_manager.auto_play_slides_loop.setChecked.call_count == 0, 'Should not be called' + assert service_manager.timed_slide_interval.setChecked.call_count == 0, 'Should not be called' + assert service_manager.theme_menu.menuAction().setVisible.call_count == 1, \ + 'Should have be called once' # THEN we add a 2nd display frame and regenerate the menu. service_item._raw_frames.append(MagicMock()) service_manager.context_menu(1) # THEN the following additional calls should have occurred. - self.assertEqual(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 2, - 'Should have be called twice') - self.assertEqual(service_manager.auto_play_slides_once.setChecked.call_count, 1, 'Should have be called once') - self.assertEqual(service_manager.auto_play_slides_loop.setChecked.call_count, 1, 'Should have be called once') - self.assertEqual(service_manager.timed_slide_interval.setChecked.call_count, 1, 'Should have be called once') + assert service_manager.auto_play_slides_menu.menuAction().setVisible.call_count == 2, \ + 'Should have be called twice' + assert service_manager.auto_play_slides_once.setChecked.call_count == 1, 'Should have be called once' + assert service_manager.auto_play_slides_loop.setChecked.call_count == 1, 'Should have be called once' + assert service_manager.timed_slide_interval.setChecked.call_count == 1, 'Should have be called once' def test_build_media_context_menu(self): """ @@ -422,25 +422,25 @@ # WHEN I define a context menu service_manager.context_menu(1) # THEN the following calls should have occurred. - self.assertEqual(service_manager.edit_action.setVisible.call_count, 1, 'Should have be called once') - self.assertEqual(service_manager.rename_action.setVisible.call_count, 2, 'Should have be called twice') - self.assertEqual(service_manager.create_custom_action.setVisible.call_count, 1, 'Should have be called once') - self.assertEqual(service_manager.maintain_action.setVisible.call_count, 1, 'Should have be called once') - self.assertEqual(service_manager.notes_action.setVisible.call_count, 1, 'Should have be called once') - self.assertEqual(service_manager.time_action.setVisible.call_count, 1, 'Should have be called once') - self.assertEqual(service_manager.auto_start_action.setVisible.call_count, 2, 'Should have be called twice') - self.assertEqual(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 1, - 'Should have be called once') - self.assertEqual(service_manager.auto_play_slides_once.setChecked.call_count, 0, 'Should not be called') - self.assertEqual(service_manager.auto_play_slides_loop.setChecked.call_count, 0, 'Should not be called') - self.assertEqual(service_manager.timed_slide_interval.setChecked.call_count, 0, 'Should not be called') - self.assertEqual(service_manager.theme_menu.menuAction().setVisible.call_count, 1, - 'Should have be called once') + assert service_manager.edit_action.setVisible.call_count == 1, 'Should have be called once' + assert service_manager.rename_action.setVisible.call_count == 2, 'Should have be called twice' + assert service_manager.create_custom_action.setVisible.call_count == 1, 'Should have be called once' + assert service_manager.maintain_action.setVisible.call_count == 1, 'Should have be called once' + assert service_manager.notes_action.setVisible.call_count == 1, 'Should have be called once' + assert service_manager.time_action.setVisible.call_count == 1, 'Should have be called once' + assert service_manager.auto_start_action.setVisible.call_count == 2, 'Should have be called twice' + assert service_manager.auto_play_slides_menu.menuAction().setVisible.call_count == 1, \ + 'Should have be called once' + assert service_manager.auto_play_slides_once.setChecked.call_count == 0, 'Should not be called' + assert service_manager.auto_play_slides_loop.setChecked.call_count == 0, 'Should not be called' + assert service_manager.timed_slide_interval.setChecked.call_count == 0, 'Should not be called' + assert service_manager.theme_menu.menuAction().setVisible.call_count == 1, \ + 'Should have be called once' # THEN I change the length of the media and regenerate the menu. service_item.set_media_length(5) service_manager.context_menu(1) # THEN the following additional calls should have occurred. - self.assertEqual(service_manager.time_action.setVisible.call_count, 3, 'Should have be called three times') + assert service_manager.time_action.setVisible.call_count == 3, 'Should have be called three times' def test_build_presentation_pdf_context_menu(self): """ @@ -480,20 +480,20 @@ # WHEN I define a context menu service_manager.context_menu(1) # THEN the following calls should have occurred. - self.assertEqual(service_manager.edit_action.setVisible.call_count, 1, 'Should have be called once') - self.assertEqual(service_manager.rename_action.setVisible.call_count, 1, 'Should have be called once') - self.assertEqual(service_manager.create_custom_action.setVisible.call_count, 1, 'Should have be called once') - self.assertEqual(service_manager.maintain_action.setVisible.call_count, 2, 'Should have be called twice') - self.assertEqual(service_manager.notes_action.setVisible.call_count, 1, 'Should have be called once') - self.assertEqual(service_manager.time_action.setVisible.call_count, 1, 'Should have be called once') - self.assertEqual(service_manager.auto_start_action.setVisible.call_count, 1, 'Should have be called once') - self.assertEqual(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 1, - 'Should have be called once') - self.assertEqual(service_manager.auto_play_slides_once.setChecked.call_count, 0, 'Should not be called') - self.assertEqual(service_manager.auto_play_slides_loop.setChecked.call_count, 0, 'Should not be called') - self.assertEqual(service_manager.timed_slide_interval.setChecked.call_count, 0, 'Should not be called') - self.assertEqual(service_manager.theme_menu.menuAction().setVisible.call_count, 1, - 'Should have be called once') + assert service_manager.edit_action.setVisible.call_count == 1, 'Should have be called once' + assert service_manager.rename_action.setVisible.call_count == 1, 'Should have be called once' + assert service_manager.create_custom_action.setVisible.call_count == 1, 'Should have be called once' + assert service_manager.maintain_action.setVisible.call_count == 2, 'Should have be called twice' + assert service_manager.notes_action.setVisible.call_count == 1, 'Should have be called once' + assert service_manager.time_action.setVisible.call_count == 1, 'Should have be called once' + assert service_manager.auto_start_action.setVisible.call_count == 1, 'Should have be called once' + assert service_manager.auto_play_slides_menu.menuAction().setVisible.call_count == 1, \ + 'Should have be called once' + assert service_manager.auto_play_slides_once.setChecked.call_count == 0, 'Should not be called' + assert service_manager.auto_play_slides_loop.setChecked.call_count == 0, 'Should not be called' + assert service_manager.timed_slide_interval.setChecked.call_count == 0, 'Should not be called' + assert service_manager.theme_menu.menuAction().setVisible.call_count == 1, \ + 'Should have be called once' def test_build_presentation_non_pdf_context_menu(self): """ @@ -530,20 +530,20 @@ # WHEN I define a context menu service_manager.context_menu(1) # THEN the following calls should have occurred. - self.assertEqual(service_manager.edit_action.setVisible.call_count, 1, 'Should have be called once') - self.assertEqual(service_manager.rename_action.setVisible.call_count, 1, 'Should have be called once') - self.assertEqual(service_manager.create_custom_action.setVisible.call_count, 1, 'Should have be called once') - self.assertEqual(service_manager.maintain_action.setVisible.call_count, 1, 'Should have be called once') - self.assertEqual(service_manager.notes_action.setVisible.call_count, 1, 'Should have be called once') - self.assertEqual(service_manager.time_action.setVisible.call_count, 1, 'Should have be called once') - self.assertEqual(service_manager.auto_start_action.setVisible.call_count, 1, 'Should have be called once') - self.assertEqual(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 1, - 'Should have be called once') - self.assertEqual(service_manager.auto_play_slides_once.setChecked.call_count, 0, 'Should not be called') - self.assertEqual(service_manager.auto_play_slides_loop.setChecked.call_count, 0, 'Should not be called') - self.assertEqual(service_manager.timed_slide_interval.setChecked.call_count, 0, 'Should not be called') - self.assertEqual(service_manager.theme_menu.menuAction().setVisible.call_count, 1, - 'Should have be called once') + assert service_manager.edit_action.setVisible.call_count == 1, 'Should have be called once' + assert service_manager.rename_action.setVisible.call_count == 1, 'Should have be called once' + assert service_manager.create_custom_action.setVisible.call_count == 1, 'Should have be called once' + assert service_manager.maintain_action.setVisible.call_count == 1, 'Should have be called once' + assert service_manager.notes_action.setVisible.call_count == 1, 'Should have be called once' + assert service_manager.time_action.setVisible.call_count == 1, 'Should have be called once' + assert service_manager.auto_start_action.setVisible.call_count == 1, 'Should have be called once' + assert service_manager.auto_play_slides_menu.menuAction().setVisible.call_count == 1, \ + 'Should have be called once' + assert service_manager.auto_play_slides_once.setChecked.call_count == 0, 'Should not be called' + assert service_manager.auto_play_slides_loop.setChecked.call_count == 0, 'Should not be called' + assert service_manager.timed_slide_interval.setChecked.call_count == 0, 'Should not be called' + assert service_manager.theme_menu.menuAction().setVisible.call_count == 1, \ + 'Should have be called once' @patch('openlp.core.ui.servicemanager.Settings') @patch('PyQt5.QtCore.QTimer.singleShot') @@ -576,7 +576,7 @@ # WHEN: on_single_click_preview() is called service_manager.on_single_click_preview() # THEN: timer should not be started - self.assertEqual(mocked_singleShot.call_count, 0, 'Should not be called') + assert mocked_singleShot.call_count == 0, 'Should not be called' @patch('openlp.core.ui.servicemanager.Settings') @patch('PyQt5.QtCore.QTimer.singleShot') @@ -595,7 +595,7 @@ service_manager.on_single_click_preview() # THEN: timer should not be started mocked_make_live.assert_called_with() - self.assertEqual(mocked_singleShot.call_count, 0, 'Should not be called') + assert mocked_singleShot.call_count == 0, 'Should not be called' @patch('openlp.core.ui.servicemanager.ServiceManager.make_preview') def test_single_click_timeout_single(self, mocked_make_preview): @@ -607,8 +607,7 @@ # WHEN: on_single_click_preview() is called service_manager.on_single_click_preview_timeout() # THEN: make_preview() should have been called - self.assertEqual(mocked_make_preview.call_count, 1, - 'ServiceManager.make_preview() should have been called once') + assert mocked_make_preview.call_count == 1, 'ServiceManager.make_preview() should have been called once' @patch('openlp.core.ui.servicemanager.ServiceManager.make_preview') @patch('openlp.core.ui.servicemanager.ServiceManager.make_live') @@ -622,7 +621,7 @@ service_manager.on_double_click_live() service_manager.on_single_click_preview_timeout() # THEN: make_preview() should not have been called - self.assertEqual(mocked_make_preview.call_count, 0, 'ServiceManager.make_preview() should not be called') + assert mocked_make_preview.call_count == 0, 'ServiceManager.make_preview() should not be called' @patch('openlp.core.ui.servicemanager.shutil.copy') @patch('openlp.core.ui.servicemanager.zipfile') @@ -650,7 +649,7 @@ result = service_manager.save_file() # THEN: The "save_as" method is called to save the service - self.assertTrue(result) + assert result is True mocked_save_file_as.assert_called_with() @patch('openlp.core.ui.servicemanager.shutil.copy') @@ -678,7 +677,7 @@ result = service_manager.save_local_file() # THEN: The "save_as" method is called to save the service - self.assertTrue(result) + assert result is True mocked_save_file_as.assert_called_with() @patch('openlp.core.ui.servicemanager.ServiceManager.regenerate_service_items') @@ -699,8 +698,8 @@ service_manager.theme_change() # THEN: The the theme toolbar should not be visible - self.assertFalse(service_manager.toolbar.actions['theme_combo_box'].isVisible(), - 'The visibility should be False') + assert service_manager.toolbar.actions['theme_combo_box'].isVisible() is False, \ + 'The visibility should be False' @patch('openlp.core.ui.servicemanager.ServiceManager.regenerate_service_items') def test_theme_change_service(self, mocked_regenerate_service_items): @@ -720,8 +719,8 @@ service_manager.theme_change() # THEN: The the theme toolbar should be visible - self.assertTrue(service_manager.toolbar.actions['theme_combo_box'].isVisible(), - 'The visibility should be True') + assert service_manager.toolbar.actions['theme_combo_box'].isVisible() is True, \ + 'The visibility should be True' @patch('openlp.core.ui.servicemanager.ServiceManager.regenerate_service_items') def test_theme_change_song(self, mocked_regenerate_service_items): @@ -741,5 +740,5 @@ service_manager.theme_change() # THEN: The the theme toolbar should be visible - self.assertTrue(service_manager.toolbar.actions['theme_combo_box'].isVisible(), - 'The visibility should be True') + assert service_manager.toolbar.actions['theme_combo_box'].isVisible() is True, \ + 'The visibility should be True' === modified file 'tests/functional/openlp_core/ui/test_settingsform.py' --- tests/functional/openlp_core/ui/test_settingsform.py 2017-10-07 07:05:07 +0000 +++ tests/functional/openlp_core/ui/test_settingsform.py 2017-12-20 21:28:03 +0000 @@ -57,7 +57,7 @@ # THEN: The general tab should have been inserted into the stacked layout and an item inserted into the list mocked_add_widget.assert_called_with(general_tab) - self.assertEqual(1, mocked_add_item.call_count, 'addItem should have been called') + assert 1 == mocked_add_item.call_count, 'addItem should have been called' def test_insert_tab_not_visible(self): """ @@ -75,7 +75,7 @@ # THEN: The general tab should have been inserted, but no list item should have been inserted into the list mocked_add_widget.assert_called_with(general_tab) - self.assertEqual(0, mocked_add_item.call_count, 'addItem should not have been called') + assert 0 == mocked_add_item.call_count, 'addItem should not have been called' def test_accept_with_inactive_plugins(self): """ @@ -107,7 +107,7 @@ # THEN: The general tab's save() method should have been called, but not the themes tab mocked_general_save.assert_called_with() - self.assertEqual(0, mocked_theme_save.call_count, 'The Themes tab\'s save() should not have been called') + assert 0 == mocked_theme_save.call_count, 'The Themes tab\'s save() should not have been called' def test_list_item_changed_invalid_item(self): """ @@ -128,7 +128,7 @@ settings_form.list_item_changed(100) # THEN: The rest of the method should not have been called - self.assertEqual(0, mocked_count.call_count, 'The count method of the stacked layout should not be called') + assert 0 == mocked_count.call_count, 'The count method of the stacked layout should not be called' def test_reject_with_inactive_items(self): """ @@ -158,7 +158,7 @@ # THEN: The general tab's cancel() method should have been called, but not the themes tab mocked_general_cancel.assert_called_with() - self.assertEqual(0, mocked_theme_cancel.call_count, 'The Themes tab\'s cancel() should not have been called') + assert 0 == mocked_theme_cancel.call_count, 'The Themes tab\'s cancel() should not have been called' def test_register_post_process(self): """ === modified file 'tests/functional/openlp_core/ui/test_slidecontroller.py' --- tests/functional/openlp_core/ui/test_slidecontroller.py 2017-11-09 21:24:38 +0000 +++ tests/functional/openlp_core/ui/test_slidecontroller.py 2017-12-20 21:28:03 +0000 @@ -29,12 +29,18 @@ from openlp.core.common.registry import Registry from openlp.core.lib import ServiceItemAction -from openlp.core.ui import SlideController, LiveController, PreviewController +from openlp.core.ui.slidecontroller import SlideController, LiveController, PreviewController from openlp.core.ui.slidecontroller import InfoLabel, WIDE_MENU, NON_TEXT_MENU class TestSlideController(TestCase): + def setUp(self): + """ + Set up the components need for all tests. + """ + Registry.create() + def test_initial_slide_controller(self): """ Test the initial slide controller state . @@ -44,7 +50,7 @@ # WHEN: the default controller is built. # THEN: The controller should not be a live controller. - self.assertEqual(slide_controller.is_live, False, 'The base slide controller should not be a live controller') + assert slide_controller.is_live is False, 'The base slide controller should not be a live controller' def test_text_service_item_blank(self): """ @@ -121,8 +127,8 @@ # THEN: Only on_blank_display() should have been called with an argument of True mocked_on_blank_display.assert_called_once_with(True) - self.assertEqual(0, mocked_on_theme_display.call_count, 'on_theme_display should not have been called') - self.assertEqual(0, mocked_on_hide_display.call_count, 'on_hide_display should not have been called') + assert 0 == mocked_on_theme_display.call_count, 'on_theme_display should not have been called' + assert 0 == mocked_on_hide_display.call_count, 'on_hide_display should not have been called' def test_toggle_display_hide(self): """ @@ -142,8 +148,8 @@ # THEN: Only on_blank_display() should have been called with an argument of True mocked_on_blank_display.assert_called_once_with(True) - self.assertEqual(0, mocked_on_theme_display.call_count, 'on_theme_display should not have been called') - self.assertEqual(0, mocked_on_hide_display.call_count, 'on_hide_display should not have been called') + assert 0 == mocked_on_theme_display.call_count, 'on_theme_display should not have been called' + assert 0 == mocked_on_hide_display.call_count, 'on_hide_display should not have been called' def test_toggle_display_theme(self): """ @@ -163,8 +169,8 @@ # THEN: Only on_theme_display() should have been called with an argument of True mocked_on_theme_display.assert_called_once_with(True) - self.assertEqual(0, mocked_on_blank_display.call_count, 'on_blank_display should not have been called') - self.assertEqual(0, mocked_on_hide_display.call_count, 'on_hide_display should not have been called') + assert 0 == mocked_on_blank_display.call_count, 'on_blank_display should not have been called' + assert 0 == mocked_on_hide_display.call_count, 'on_hide_display should not have been called' def test_toggle_display_desktop(self): """ @@ -184,8 +190,8 @@ # THEN: Only on_hide_display() should have been called with an argument of True mocked_on_hide_display.assert_called_once_with(True) - self.assertEqual(0, mocked_on_blank_display.call_count, 'on_blank_display should not have been called') - self.assertEqual(0, mocked_on_theme_display.call_count, 'on_theme_display should not have been called') + assert 0 == mocked_on_blank_display.call_count, 'on_blank_display should not have been called' + assert 0 == mocked_on_theme_display.call_count, 'on_theme_display should not have been called' def test_toggle_display_show(self): """ @@ -348,7 +354,7 @@ # THEN: The value of slide_limits should be 10 mocked_value.assert_called_once_with('advanced/slide limits') - self.assertEqual(10, slide_controller.slide_limits, 'Slide limits should have been updated to 10') + assert 10 == slide_controller.slide_limits, 'Slide limits should have been updated to 10' def test_enable_tool_bar_live(self): """ @@ -368,7 +374,7 @@ # THEN: The enable_live_tool_bar() method is called, not enable_preview_tool_bar() mocked_enable_live_tool_bar.assert_called_once_with(mocked_service_item) - self.assertEqual(0, mocked_enable_preview_tool_bar.call_count, 'The preview method should not have been called') + assert 0 == mocked_enable_preview_tool_bar.call_count, 'The preview method should not have been called' def test_enable_tool_bar_preview(self): """ @@ -388,7 +394,7 @@ # THEN: The enable_preview_tool_bar() method is called, not enable_live_tool_bar() mocked_enable_preview_tool_bar.assert_called_once_with(mocked_service_item) - self.assertEqual(0, mocked_enable_live_tool_bar.call_count, 'The live method should not have been called') + assert 0 == mocked_enable_live_tool_bar.call_count, 'The live method should not have been called' def test_refresh_service_item_text(self): """ @@ -409,7 +415,7 @@ # THEN: The item should be re-processed mocked_service_item.is_text.assert_called_once_with() - self.assertEqual(0, mocked_service_item.is_image.call_count, 'is_image should not have been called') + assert 0 == mocked_service_item.is_image.call_count, 'is_image should not have been called' mocked_service_item.render.assert_called_once_with() mocked_process_item.assert_called_once_with(mocked_service_item, 5) @@ -456,9 +462,8 @@ # THEN: The item should be re-processed mocked_service_item.is_text.assert_called_once_with() mocked_service_item.is_image.assert_called_once_with() - self.assertEqual(0, mocked_service_item.render.call_count, 'The render() method should not have been called') - self.assertEqual(0, mocked_process_item.call_count, - 'The mocked_process_item() method should not have been called') + assert 0 == mocked_service_item.render.call_count, 'The render() method should not have been called' + assert 0 == mocked_process_item.call_count, 'The mocked_process_item() method should not have been called' def test_add_service_item_with_song_edit(self): """ @@ -477,7 +482,7 @@ # THEN: The item is processed, the slide number is correct, and the song is not editable (or something) mocked_item.render.assert_called_once_with() - self.assertFalse(slide_controller.song_edit, 'song_edit should be False') + assert slide_controller.song_edit is False, 'song_edit should be False' mocked_process_item.assert_called_once_with(mocked_item, 2) def test_add_service_item_without_song_edit(self): @@ -497,7 +502,7 @@ # THEN: The item is processed, the slide number is correct, and the song is not editable (or something) mocked_item.render.assert_called_once_with() - self.assertFalse(slide_controller.song_edit, 'song_edit should be False') + assert slide_controller.song_edit is False, 'song_edit should be False' mocked_process_item.assert_called_once_with(mocked_item, 0) def test_replace_service_manager_item_different_items(self): @@ -517,9 +522,9 @@ slide_controller.replace_service_manager_item(mocked_item) # THEN: The service item should not be processed - self.assertEqual(0, mocked_process_item.call_count, 'The _process_item() method should not have been called') - self.assertEqual(0, mocked_preview_widget.current_slide_number.call_count, - 'The preview_widgetcurrent_slide_number.() method should not have been called') + assert 0 == mocked_process_item.call_count, 'The _process_item() method should not have been called' + assert 0 == mocked_preview_widget.current_slide_number.call_count, \ + 'The preview_widget current_slide_number.() method should not have been called' def test_replace_service_manager_item_same_item(self): """ @@ -583,7 +588,7 @@ slide_controller.on_slide_selected_index([10]) # THEN: It should have exited early - self.assertEqual(0, mocked_item.is_command.call_count, 'The service item should have not been called') + assert 0 == mocked_item.is_command.call_count, 'The service item should have not been called' @patch.object(Registry, 'execute') def test_on_slide_selected_index_service_item_command(self, mocked_execute): @@ -612,8 +617,8 @@ mocked_item.is_command.assert_called_once_with() mocked_execute.assert_called_once_with('mocked item_slide', [mocked_item, True, 9]) mocked_update_preview.assert_called_once_with() - self.assertEqual(0, mocked_preview_widget.change_slide.call_count, 'Change slide should not have been called') - self.assertEqual(0, mocked_slide_selected.call_count, 'slide_selected should not have been called') + assert 0 == mocked_preview_widget.change_slide.call_count, 'Change slide should not have been called' + assert 0 == mocked_slide_selected.call_count, 'slide_selected should not have been called' @patch.object(Registry, 'execute') def test_on_slide_selected_index_service_item_not_command(self, mocked_execute): @@ -639,8 +644,8 @@ # THEN: It should have sent a notification mocked_item.is_command.assert_called_once_with() - self.assertEqual(0, mocked_execute.call_count, 'Execute should not have been called') - self.assertEqual(0, mocked_update_preview.call_count, 'Update preview should not have been called') + assert 0 == mocked_execute.call_count, 'Execute should not have been called' + assert 0 == mocked_update_preview.call_count, 'Update preview should not have been called' mocked_preview_widget.change_slide.assert_called_once_with(7) mocked_slide_selected.assert_called_once_with() @@ -685,9 +690,9 @@ slide_controller._process_item(mocked_media_item, 0) # THEN: Registry.execute should have been called to stop the presentation - self.assertEqual(2, mocked_execute.call_count, 'Execute should have been called 2 times') - self.assertEqual('mocked_presentation_item_stop', mocked_execute.call_args_list[1][0][0], - 'The presentation should have been stopped.') + assert 2 == mocked_execute.call_count, 'Execute should have been called 2 times' + assert 'mocked_presentation_item_stop' == mocked_execute.call_args_list[1][0][0], \ + 'The presentation should have been stopped.' def test_live_stolen_focus_shortcuts(self): """ @@ -737,8 +742,8 @@ slide_controller.on_preview_double_click() # THEN: The call to addActions should be correct - self.assertEqual(1, slide_controller.on_go_live.call_count, 'on_go_live should have been called once.') - self.assertEqual(0, slide_controller.on_preview_add_to_service.call_count, 'Should have not been called.') + assert 1 == slide_controller.on_go_live.call_count, 'on_go_live should have been called once.' + assert 0 == slide_controller.on_preview_add_to_service.call_count, 'Should have not been called.' @patch('openlp.core.ui.slidecontroller.Settings') def test_on_preview_double_click_add_to_service(self, MockedSettings): @@ -760,8 +765,8 @@ slide_controller.on_preview_double_click() # THEN: The call to addActions should be correct - self.assertEqual(0, slide_controller.on_go_live.call_count, 'on_go_live Should have not been called.') - self.assertEqual(1, slide_controller.on_preview_add_to_service.call_count, 'Should have been called once.') + assert 0 == slide_controller.on_go_live.call_count, 'on_go_live Should have not been called.' + assert 1 == slide_controller.on_preview_add_to_service.call_count, 'Should have been called once.' @patch(u'openlp.core.ui.slidecontroller.SlideController.image_manager') @patch(u'PyQt5.QtCore.QTimer.singleShot') @@ -800,11 +805,10 @@ slide_controller.update_preview() # THEN: A screen_grab should have been called - self.assertEqual(0, slide_controller.slide_preview.setPixmap.call_count, 'setPixmap should not be called') - self.assertEqual(0, slide_controller.display.preview.call_count, 'display.preview() should not be called') - self.assertEqual(2, mocked_singleShot.call_count, - 'Timer to grab_maindisplay should have been called 2 times') - self.assertEqual(0, mocked_image_manager.get_image.call_count, 'image_manager not be called') + assert 0 == slide_controller.slide_preview.setPixmap.call_count, 'setPixmap should not be called' + assert 0 == slide_controller.display.preview.call_count, 'display.preview() should not be called' + assert 2 == mocked_singleShot.call_count, 'Timer to grab_maindisplay should have been called 2 times' + assert 0 == mocked_image_manager.get_image.call_count, 'image_manager not be called' @patch(u'openlp.core.ui.slidecontroller.SlideController.image_manager') @patch(u'PyQt5.QtCore.QTimer.singleShot') @@ -843,10 +847,10 @@ slide_controller.update_preview() # THEN: setPixmap and the image_manager should have been called - self.assertEqual(1, slide_controller.slide_preview.setPixmap.call_count, 'setPixmap should be called') - self.assertEqual(0, slide_controller.display.preview.call_count, 'display.preview() should not be called') - self.assertEqual(0, mocked_singleShot.call_count, 'Timer to grab_maindisplay should not be called') - self.assertEqual(1, mocked_image_manager.get_image.call_count, 'image_manager should be called') + assert 1 == slide_controller.slide_preview.setPixmap.call_count, 'setPixmap should be called' + assert 0 == slide_controller.display.preview.call_count, 'display.preview() should not be called' + assert 0 == mocked_singleShot.call_count, 'Timer to grab_maindisplay should not be called' + assert 1 == mocked_image_manager.get_image.call_count, 'image_manager should be called' @patch(u'openlp.core.ui.slidecontroller.SlideController.image_manager') @patch(u'PyQt5.QtCore.QTimer.singleShot') @@ -885,10 +889,10 @@ slide_controller.update_preview() # THEN: setPixmap should have been called - self.assertEqual(1, slide_controller.slide_preview.setPixmap.call_count, 'setPixmap should be called') - self.assertEqual(0, slide_controller.display.preview.call_count, 'display.preview() should not be called') - self.assertEqual(0, mocked_singleShot.call_count, 'Timer to grab_maindisplay should not be called') - self.assertEqual(0, mocked_image_manager.get_image.call_count, 'image_manager should not be called') + assert 1 == slide_controller.slide_preview.setPixmap.call_count, 'setPixmap should be called' + assert 0 == slide_controller.display.preview.call_count, 'display.preview() should not be called' + assert 0 == mocked_singleShot.call_count, 'Timer to grab_maindisplay should not be called' + assert 0 == mocked_image_manager.get_image.call_count, 'image_manager should not be called' @patch(u'openlp.core.ui.slidecontroller.SlideController.image_manager') @patch(u'PyQt5.QtCore.QTimer.singleShot') @@ -927,10 +931,10 @@ slide_controller.update_preview() # THEN: setPixmap and display.preview should have been called - self.assertEqual(1, slide_controller.slide_preview.setPixmap.call_count, 'setPixmap should be called') - self.assertEqual(1, slide_controller.display.preview.call_count, 'display.preview() should be called') - self.assertEqual(0, mocked_singleShot.call_count, 'Timer to grab_maindisplay should not be called') - self.assertEqual(0, mocked_image_manager.get_image.call_count, 'image_manager should not be called') + assert 1 == slide_controller.slide_preview.setPixmap.call_count, 'setPixmap should be called' + assert 1 == slide_controller.display.preview.call_count, 'display.preview() should be called' + assert 0 == mocked_singleShot.call_count, 'Timer to grab_maindisplay should not be called' + assert 0 == mocked_image_manager.get_image.call_count, 'image_manager should not be called' class TestInfoLabel(TestCase): @@ -1023,7 +1027,7 @@ # WHEN: the default controller is built. # THEN: The controller should not be a live controller. - self.assertEqual(live_controller.is_live, True, 'The slide controller should be a live controller') + assert live_controller.is_live is True, 'The slide controller should be a live controller' class TestPreviewLiveController(TestCase): @@ -1038,4 +1042,4 @@ # WHEN: the default controller is built. # THEN: The controller should not be a live controller. - self.assertEqual(preview_controller.is_live, False, 'The slide controller should be a Preview controller') + assert preview_controller.is_live is False, 'The slide controller should be a Preview controller' === modified file 'tests/functional/openlp_core/ui/test_themeform.py' --- tests/functional/openlp_core/ui/test_themeform.py 2017-09-26 16:39:13 +0000 +++ tests/functional/openlp_core/ui/test_themeform.py 2017-12-20 21:28:03 +0000 @@ -49,5 +49,5 @@ self.instance.on_image_path_edit_path_changed(Path('/', 'new', 'pat.h')) # THEN: The theme background file should be set and `set_background_page_values` should have been called - self.assertEqual(self.instance.theme.background_filename, Path('/', 'new', 'pat.h')) + assert self.instance.theme.background_filename == Path('/', 'new', 'pat.h') mocked_set_background_page_values.assert_called_once_with() === modified file 'tests/functional/openlp_core/ui/test_thememanager.py' --- tests/functional/openlp_core/ui/test_thememanager.py 2017-11-18 11:23:15 +0000 +++ tests/functional/openlp_core/ui/test_thememanager.py 2017-12-20 21:28:03 +0000 @@ -80,7 +80,7 @@ # WHEN: the default theme manager is built. # THEN: The the controller should be registered in the registry. - self.assertIsNotNone(Registry().get('theme_manager'), 'The base theme manager should be registered') + assert Registry().get('theme_manager') is not None, 'The base theme manager should be registered' @patch('openlp.core.ui.thememanager.copyfile') @patch('openlp.core.ui.thememanager.create_paths') @@ -147,8 +147,8 @@ theme_manager._write_theme(mocked_theme, None, None) # THEN: It should have been created - self.assertTrue(os.path.exists(os.path.join(self.temp_folder, 'theme 愛 name', 'theme 愛 name.json')), - 'Theme with special characters should have been created!') + assert os.path.exists(os.path.join(self.temp_folder, 'theme 愛 name', 'theme 愛 name.json')) is True, \ + 'Theme with special characters should have been created!' @patch('openlp.core.ui.thememanager.QtWidgets.QMessageBox.question', return_value=QtWidgets.QMessageBox.Yes) @patch('openlp.core.ui.thememanager.translate') @@ -206,8 +206,8 @@ theme_manager.unzip_theme(theme_file, folder_path) # THEN: Files should be unpacked - self.assertTrue((folder_path / 'Moss on tree' / 'Moss on tree.xml').exists()) - self.assertEqual(mocked_critical_error_message_box.call_count, 0, 'No errors should have happened') + assert (folder_path / 'Moss on tree' / 'Moss on tree.xml').exists() is True + assert mocked_critical_error_message_box.call_count == 0, 'No errors should have happened' folder_path.rmtree() def test_unzip_theme_invalid_version(self): @@ -228,4 +228,4 @@ theme_manager.unzip_theme('theme.file', 'folder') # THEN: The critical_error_message_box should have been called - self.assertEqual(mocked_critical_error_message_box.call_count, 1, 'Should have been called once') + assert mocked_critical_error_message_box.call_count == 1, 'Should have been called once' === modified file 'tests/functional/openlp_core/ui/test_themetab.py' --- tests/functional/openlp_core/ui/test_themetab.py 2017-10-07 07:05:07 +0000 +++ tests/functional/openlp_core/ui/test_themetab.py 2017-12-20 21:28:03 +0000 @@ -51,7 +51,7 @@ themes_tab = ThemesTab(settings_form) # THEN: - self.assertEqual("Themes", themes_tab.tab_title, 'The tab title should be Theme') + assert "Themes" == themes_tab.tab_title, 'The tab title should be Theme' def test_save_triggers_processes_true(self): """ @@ -66,7 +66,7 @@ themes_tab.save() # THEN: we should have two post save processed to run - self.assertEqual(1, len(settings_form.processes), 'One post save processes should be created') + assert 1 == len(settings_form.processes), 'One post save processes should be created' def test_save_triggers_processes_false(self): """ @@ -81,4 +81,4 @@ themes_tab.save() # THEN: we should have two post save processed to run - self.assertEqual(0, len(settings_form.processes), 'No post save processes should be created') + assert 0 == len(settings_form.processes), 'No post save processes should be created' === modified file 'tests/functional/openlp_core/widgets/test_buttons.py' --- tests/functional/openlp_core/widgets/test_buttons.py 2017-10-23 22:09:57 +0000 +++ tests/functional/openlp_core/widgets/test_buttons.py 2017-12-20 21:28:03 +0000 @@ -60,8 +60,7 @@ widget = ColorButton() # THEN: The widget __init__ method should have the correct properties and methods called - self.assertEqual(widget.parent, None, - 'The parent should be the same as the one that the class was instianted with') + assert widget.parent is None, 'The parent should be the same as the one that the class was instianted with' self.mocked_change_color.assert_called_once_with('#ffffff') mocked_set_tool_tip.assert_called_once_with('Tool Tip Text') self.mocked_clicked.connect.assert_called_once_with(widget.on_clicked) @@ -80,7 +79,7 @@ widget.change_color('#000000') # THEN: The _color attribute should be set to #000000 and setStyleSheet should have been called twice - self.assertEqual(widget._color, '#000000', '_color should have been set to #000000') + assert widget._color == '#000000', '_color should have been set to #000000' mocked_set_style_sheet.assert_has_calls( [call('background-color: #ffffff'), call('background-color: #000000')]) @@ -98,7 +97,7 @@ value = widget.color # THEN: The value set in _color should be returned - self.assertEqual(value, '#000000', 'The value returned should be equal to the one we set') + assert value == '#000000', 'The value returned should be equal to the one we set' # @patch('openlp.core.widgets.buttons.ColorButton.__init__', **{'return_value': None}) def test_color_setter(self): @@ -130,10 +129,10 @@ widget.on_clicked() # THEN: change_color should not have been called and the colorChanged signal should not have been emitted - self.assertFalse(self.mocked_change_color.called, - 'change_color should not have been called with an invalid color') - self.assertFalse(self.mocked_color_changed.emit.called, - 'colorChange signal should not have been emitted with an invalid color') + assert self.mocked_change_color.called is False, \ + 'change_color should not have been called with an invalid color' + assert self.mocked_color_changed.emit.called is False, \ + 'colorChange signal should not have been emitted with an invalid color' def test_on_clicked_same_color(self): """ @@ -152,10 +151,10 @@ widget.on_clicked() # THEN: change_color should not have been called and the colorChanged signal should not have been emitted - self.assertFalse(self.mocked_change_color.called, - 'change_color should not have been called when the color has not changed') - self.assertFalse(self.mocked_color_changed.emit.called, - 'colorChange signal should not have been emitted when the color has not changed') + assert self.mocked_change_color.called is False, \ + 'change_color should not have been called when the color has not changed' + assert self.mocked_color_changed.emit.called is False, \ + 'colorChange signal should not have been emitted when the color has not changed' def test_on_clicked_new_color(self): """ === modified file 'tests/functional/openlp_core/widgets/test_dialogs.py' --- tests/functional/openlp_core/widgets/test_dialogs.py 2017-10-23 22:09:57 +0000 +++ tests/functional/openlp_core/widgets/test_dialogs.py 2017-12-20 21:28:03 +0000 @@ -22,7 +22,7 @@ instance = FileDialog() # THEN: The instance should be an instance of QFileDialog - self.assertIsInstance(instance, QtWidgets.QFileDialog) + assert isinstance(instance, QtWidgets.QFileDialog) def test_get_existing_directory_user_abort(self): """ @@ -34,7 +34,7 @@ result = FileDialog.getExistingDirectory() # THEN: The result should be None - self.assertEqual(result, None) + assert result is None def test_get_existing_directory_user_accepts(self): """ @@ -47,7 +47,7 @@ result = FileDialog.getExistingDirectory() # THEN: getExistingDirectory() should return a Path object pointing to the chosen file - self.assertEqual(result, Path('test', 'dir')) + assert result == Path('test', 'dir') def test_get_existing_directory_param_order(self): """ @@ -77,7 +77,7 @@ result = FileDialog.getOpenFileName() # THEN: First value should be None - self.assertEqual(result[0], None) + assert result[0] is None def test_get_open_file_name_user_accepts(self): """ @@ -92,7 +92,7 @@ # THEN: getOpenFileName() should return a tuple with the first value set to a Path object pointing to the # chosen file - self.assertEqual(result[0], Path('test', 'chosen.file')) + assert result[0] == Path('test', 'chosen.file') def test_get_open_file_name_selected_filter(self): """ @@ -104,7 +104,7 @@ result = FileDialog.getOpenFileName() # THEN: getOpenFileName() should return a tuple with the second value set to a the selected filter - self.assertEqual(result[1], 'selected filter') + assert result[1] == 'selected filter' def test_get_open_file_names_user_abort(self): """ @@ -117,7 +117,7 @@ result = FileDialog.getOpenFileNames() # THEN: First value should be an empty list - self.assertEqual(result[0], []) + assert result[0] == [] def test_get_open_file_names_user_accepts(self): """ @@ -132,7 +132,7 @@ # THEN: getOpenFileNames() should return a tuple with the first value set to a list of Path objects pointing # to the chosen file - self.assertEqual(result[0], [Path('test', 'chosen.file1'), Path('test', 'chosen.file2')]) + assert result[0] == [Path('test', 'chosen.file1'), Path('test', 'chosen.file2')] def test_get_open_file_names_selected_filter(self): """ @@ -145,7 +145,7 @@ result = FileDialog.getOpenFileNames() # THEN: getOpenFileNames() should return a tuple with the second value set to a the selected filter - self.assertEqual(result[1], 'selected filter') + assert result[1] == 'selected filter' def test_get_save_file_name_user_abort(self): """ @@ -158,7 +158,7 @@ result = FileDialog.getSaveFileName() # THEN: First value should be None - self.assertEqual(result[0], None) + assert result[0] is None def test_get_save_file_name_user_accepts(self): """ @@ -173,7 +173,7 @@ # THEN: getSaveFileName() should return a tuple with the first value set to a Path object pointing to the # chosen file - self.assertEqual(result[0], Path('test', 'chosen.file')) + assert result[0] == Path('test', 'chosen.file') def test_get_save_file_name_selected_filter(self): """ @@ -185,4 +185,4 @@ result = FileDialog.getSaveFileName() # THEN: getSaveFileName() should return a tuple with the second value set to a the selected filter - self.assertEqual(result[1], 'selected filter') + assert result[1] == 'selected filter' === modified file 'tests/functional/openlp_core/widgets/test_edits.py' --- tests/functional/openlp_core/widgets/test_edits.py 2017-10-23 22:09:57 +0000 +++ tests/functional/openlp_core/widgets/test_edits.py 2017-12-20 21:28:03 +0000 @@ -27,9 +27,9 @@ from unittest.mock import MagicMock, PropertyMock, patch from openlp.core.common.path import Path -from openlp.core.widgets.edits import PathEdit from openlp.core.widgets.enums import PathEditType from openlp.core.widgets.dialogs import FileDialog +from openlp.core.widgets.edits import PathEdit class TestPathEdit(TestCase): @@ -49,7 +49,7 @@ # WHEN: Reading the `path` property # THEN: The value that we set should be returned - self.assertEqual(self.widget.path, Path('getter', 'test', 'pat.h')) + assert self.widget.path == Path('getter', 'test', 'pat.h') def test_path_setter(self): """ @@ -63,7 +63,7 @@ # THEN: The `_path` instance variable should be set with the test data. The `line_edit` text and tooltip # should have also been set. - self.assertEqual(self.widget._path, Path('setter', 'test', 'pat.h')) + assert self.widget._path == Path('setter', 'test', 'pat.h') self.widget.line_edit.setToolTip.assert_called_once_with(os.path.join('setter', 'test', 'pat.h')) self.widget.line_edit.setText.assert_called_once_with(os.path.join('setter', 'test', 'pat.h')) @@ -74,7 +74,7 @@ # GIVEN: An instance of PathEdit # WHEN: Reading the `path` property # THEN: The default value should be returned - self.assertEqual(self.widget.path_type, PathEditType.Files) + assert self.widget.path_type == PathEditType.Files def test_path_type_setter(self): """ @@ -88,7 +88,7 @@ # THEN: The `_path_type` instance variable should be set with the test data and not the default. The # update_button_tool_tips should have been called. - self.assertEqual(self.widget._path_type, PathEditType.Directories) + assert self.widget._path_type == PathEditType.Directories mocked_update_button_tool_tips.assert_called_once_with() def test_update_button_tool_tips_directories(self): @@ -139,7 +139,7 @@ mocked_get_existing_directory.assert_called_once_with(self.widget, 'Select Directory', Path('test', 'path'), FileDialog.ShowDirsOnly) - self.assertFalse(mocked_get_open_file_name.called) + assert mocked_get_open_file_name.called is False def test_on_browse_button_clicked_directory_custom_caption(self): """ @@ -162,7 +162,7 @@ mocked_get_existing_directory.assert_called_once_with(self.widget, 'Directory Caption', Path('test', 'path'), FileDialog.ShowDirsOnly) - self.assertFalse(mocked_get_open_file_name.called) + assert mocked_get_open_file_name.called is False def test_on_browse_button_clicked_file(self): """ @@ -181,7 +181,7 @@ # THEN: The FileDialog.getOpenFileName should have been called with the default caption mocked_get_open_file_name.assert_called_once_with(self.widget, 'Select File', Path('test', 'pat.h'), self.widget.filters) - self.assertFalse(mocked_get_existing_directory.called) + assert mocked_get_existing_directory.called is False def test_on_browse_button_clicked_file_custom_caption(self): """ @@ -203,7 +203,7 @@ # THEN: The FileDialog.getOpenFileName should have been called with the custom caption mocked_get_open_file_name.assert_called_once_with(self.widget, 'File Caption', Path('test', 'pat.h'), self.widget.filters) - self.assertFalse(mocked_get_existing_directory.called) + assert mocked_get_existing_directory.called is False def test_on_browse_button_clicked_user_cancels(self): """ @@ -219,7 +219,7 @@ self.widget.on_browse_button_clicked() # THEN: normpath should not have been called - self.assertTrue(mocked_get_open_file_name.called) + assert mocked_get_open_file_name.called is True def test_on_browse_button_clicked_user_accepts(self): """ @@ -236,8 +236,8 @@ self.widget.on_browse_button_clicked() # THEN: normpath and `on_new_path` should have been called - self.assertTrue(mocked_get_open_file_name.called) - self.assertTrue(self.widget.on_new_path.called) + assert mocked_get_open_file_name.called is True + assert self.widget.on_new_path.called is True def test_on_revert_button_clicked(self): """ @@ -280,7 +280,7 @@ self.widget.on_new_path(Path('/old', 'test', 'pat.h')) # THEN: The `pathChanged` signal should not be emitted - self.assertFalse(self.widget.pathChanged.emit.called) + assert self.widget.pathChanged.emit.called is False def test_on_new_path_change(self): """ === modified file 'tests/functional/openlp_core/widgets/test_views.py' --- tests/functional/openlp_core/widgets/test_views.py 2017-11-09 20:39:17 +0000 +++ tests/functional/openlp_core/widgets/test_views.py 2017-12-20 21:28:03 +0000 @@ -71,8 +71,8 @@ list_preview_widget = ListPreviewWidget(None, 1) # THEN: The object is not None, and the _setup() method was called. - self.assertIsNotNone(list_preview_widget, 'The ListPreviewWidget object should not be None') - self.assertEquals(list_preview_widget.screen_ratio, 1, 'Should not be called') + assert list_preview_widget is not None, 'The ListPreviewWidget object should not be None' + assert list_preview_widget.screen_ratio == 1, 'Should not be called' @patch(u'openlp.core.widgets.views.ListPreviewWidget.image_manager') @patch(u'openlp.core.widgets.views.ListPreviewWidget.resizeRowsToContents') @@ -116,7 +116,7 @@ list_preview_widget.replace_service_item(mocked_cmd_service_item, 200, 0) # THEN: The ImageManager should be called in the appriopriate manner for each service item. - self.assertEquals(mocked_image_manager.get_image.call_count, 4, 'Should be called once for each slide') + assert mocked_image_manager.get_image.call_count == 4, 'Should be called once for each slide' calls = [call('TEST1', ImageSource.ImagePlugin), call('TEST2', ImageSource.ImagePlugin), call('TEST3', ImageSource.CommandPlugins), call('TEST4', ImageSource.CommandPlugins)] mocked_image_manager.get_image.assert_has_calls(calls) @@ -150,8 +150,8 @@ # THEN: setRowHeight() should not be called, while resizeRowsToContents() should be called twice # (once each in __recalculate_layout and replace_service_item) - self.assertEquals(mocked_resizeRowsToContents.call_count, 2, 'Should be called') - self.assertEquals(mocked_setRowHeight.call_count, 0, 'Should not be called') + assert mocked_resizeRowsToContents.call_count == 2, 'Should be called' + assert mocked_setRowHeight.call_count == 0, 'Should not be called' @patch(u'openlp.core.widgets.views.ListPreviewWidget.resizeRowsToContents') @patch(u'openlp.core.widgets.views.ListPreviewWidget.setRowHeight') @@ -185,8 +185,8 @@ # THEN: resizeRowsToContents() should not be called, while setRowHeight() should be called # twice for each slide. - self.assertEquals(mocked_resizeRowsToContents.call_count, 0, 'Should not be called') - self.assertEquals(mocked_setRowHeight.call_count, 6, 'Should be called 3 times for each slide') + assert mocked_resizeRowsToContents.call_count == 0, 'Should not be called' + assert mocked_setRowHeight.call_count == 6, 'Should be called 3 times for each slide' calls = [call(0, 200), call(1, 200), call(0, 400), call(1, 400), call(0, 400), call(1, 400)] mocked_setRowHeight.assert_has_calls(calls) @@ -220,8 +220,8 @@ # THEN: resizeRowsToContents() should not be called, while setRowHeight() should be called # twice for each slide. - self.assertEquals(mocked_resizeRowsToContents.call_count, 0, 'Should not be called') - self.assertEquals(mocked_setRowHeight.call_count, 4, 'Should be called twice for each slide') + assert mocked_resizeRowsToContents.call_count == 0, 'Should not be called' + assert mocked_setRowHeight.call_count == 4, 'Should be called twice for each slide' calls = [call(0, 100), call(1, 100), call(0, 100), call(1, 100)] mocked_setRowHeight.assert_has_calls(calls) @@ -258,8 +258,8 @@ # THEN: resizeRowsToContents() should not be called, while setRowHeight() should be called # twice for each slide. - self.assertEquals(mocked_resizeRowsToContents.call_count, 0, 'Should not be called') - self.assertEquals(mocked_setRowHeight.call_count, 6, 'Should be called 3 times for each slide') + assert mocked_resizeRowsToContents.call_count == 0, 'Should not be called' + assert mocked_setRowHeight.call_count == 6, 'Should be called 3 times for each slide' calls = [call(0, 100), call(1, 100), call(0, 150), call(1, 150), call(0, 100), call(1, 100)] mocked_setRowHeight.assert_has_calls(calls) @@ -295,7 +295,7 @@ list_preview_widget.row_resized(0, 100, 150) # THEN: self.cellWidget(row, 0).children()[1].setMaximumWidth() should not be called - self.assertEquals(mocked_cellWidget_child.setMaximumWidth.call_count, 0, 'Should not be called') + assert mocked_cellWidget_child.setMaximumWidth.call_count == 0, 'Should not be called' @patch(u'openlp.core.widgets.views.ListPreviewWidget.resizeRowsToContents') @patch(u'openlp.core.widgets.views.ListPreviewWidget.setRowHeight') @@ -332,7 +332,7 @@ list_preview_widget.row_resized(0, 100, 150) # THEN: self.cellWidget(row, 0).children()[1].setMaximumWidth() should not be called - self.assertEquals(mocked_cellWidget_child.setMaximumWidth.call_count, 0, 'Should not be called') + assert mocked_cellWidget_child.setMaximumWidth.call_count == 0, 'Should not be called' @patch(u'openlp.core.widgets.views.ListPreviewWidget.resizeRowsToContents') @patch(u'openlp.core.widgets.views.ListPreviewWidget.setRowHeight') @@ -435,10 +435,10 @@ list_preview_widget.change_slide(0) # THEN: no further functions should be called - self.assertEquals(mocked_slide_count.call_count, 0, 'Should not be called') - self.assertEquals(mocked_scrollToItem.call_count, 0, 'Should not be called') - self.assertEquals(mocked_selectRow.call_count, 0, 'Should not be called') - self.assertEquals(mocked_item.call_count, 0, 'Should not be called') + assert mocked_slide_count.call_count == 0, 'Should not be called' + assert mocked_scrollToItem.call_count == 0, 'Should not be called' + assert mocked_selectRow.call_count == 0, 'Should not be called' + assert mocked_item.call_count == 0, 'Should not be called' @patch(u'openlp.core.widgets.views.ListPreviewWidget.selectRow') @patch(u'openlp.core.widgets.views.ListPreviewWidget.scrollToItem') @@ -463,10 +463,10 @@ list_preview_widget.change_slide(0) # THEN: no further functions should be called - self.assertEquals(mocked_slide_count.call_count, 3, 'Should be called') - self.assertEquals(mocked_scrollToItem.call_count, 2, 'Should be called') - self.assertEquals(mocked_selectRow.call_count, 2, 'Should be called') - self.assertEquals(mocked_item.call_count, 2, 'Should be called') + assert mocked_slide_count.call_count == 3, 'Should be called' + assert mocked_scrollToItem.call_count == 2, 'Should be called' + assert mocked_selectRow.call_count == 2, 'Should be called' + assert mocked_item.call_count == 2, 'Should be called' calls = [call(0, 0), call(0, 0)] mocked_item.assert_has_calls(calls) @@ -495,10 +495,10 @@ list_preview_widget.change_slide(1) # THEN: no further functions should be called - self.assertEquals(mocked_slide_count.call_count, 3, 'Should be called') - self.assertEquals(mocked_scrollToItem.call_count, 3, 'Should be called') - self.assertEquals(mocked_selectRow.call_count, 3, 'Should be called') - self.assertEquals(mocked_item.call_count, 3, 'Should be called') + assert mocked_slide_count.call_count == 3, 'Should be called' + assert mocked_scrollToItem.call_count == 3, 'Should be called' + assert mocked_selectRow.call_count == 3, 'Should be called' + assert mocked_item.call_count == 3, 'Should be called' calls = [call(0, 0), call(1, 0), call(2, 0)] mocked_item.assert_has_calls(calls) @@ -518,7 +518,7 @@ widget.clear() # THEN: The results text should be the standard 'no results' text. - self.assertEqual(widget.no_results_text, UiStrings().NoResults) + assert widget.no_results_text == UiStrings().NoResults def test_clear_search_while_typing(self): """ @@ -531,7 +531,7 @@ widget.clear(search_while_typing=True) # THEN: The results text should be the 'short results' text. - self.assertEqual(widget.no_results_text, UiStrings().ShortResults) + assert widget.no_results_text == UiStrings().ShortResults def test_all_items_no_list_items(self): """ @@ -546,8 +546,8 @@ result = widget.allItems() # THEN: An instance of a Generator object should be returned. The generator should not yeild any results - self.assertIsInstance(result, GeneratorType) - self.assertEqual(list(result), []) + assert isinstance(result, GeneratorType) + assert list(result) == [] def test_all_items_list_items(self): """ @@ -562,8 +562,8 @@ result = widget.allItems() # THEN: An instance of a Generator object should be returned. The generator should not yeild any results - self.assertIsInstance(result, GeneratorType) - self.assertEqual(list(result), [5, 3]) + assert isinstance(result, GeneratorType) + assert list(result) == [5, 3] def test_paint_event(self): """ @@ -582,7 +582,7 @@ # THEN: The overridden paintEvnet should have been called mocked_paint_event.assert_called_once_with(mocked_event) - self.assertFalse(mocked_viewport.called) + assert mocked_viewport.called is False def test_paint_event_no_items(self): """
_______________________________________________ Mailing list: https://launchpad.net/~openlp-core Post to : openlp-core@lists.launchpad.net Unsubscribe : https://launchpad.net/~openlp-core More help : https://help.launchpad.net/ListHelp