diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index 0c6e64546..b2e1efd32 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -25,7 +25,6 @@ OpenLP work. """ import html import logging -import os import re import math diff --git a/tests/functional/openlp_core/ui/lib/__init__.py b/tests/functional/openlp_core/ui/lib/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/functional/openlp_core/ui/media/test_mediacontroller.py b/tests/functional/openlp_core/ui/media/test_mediacontroller.py index f468b02be..c93b11f33 100644 --- a/tests/functional/openlp_core/ui/media/test_mediacontroller.py +++ b/tests/functional/openlp_core/ui/media/test_mediacontroller.py @@ -54,10 +54,10 @@ class TestMediaController(TestCase, TestMixin): 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 @@ class TestMediaController(TestCase, TestMixin): 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 @@ class TestMediaController(TestCase, TestMixin): 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 @@ class TestMediaController(TestCase, TestMixin): 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 @@ class TestMediaController(TestCase, TestMixin): 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): """ diff --git a/tests/functional/openlp_core/ui/media/test_systemplayer.py b/tests/functional/openlp_core/ui/media/test_systemplayer.py index 2fe2e0619..82caeb94c 100644 --- a/tests/functional/openlp_core/ui/media/test_systemplayer.py +++ b/tests/functional/openlp_core/ui/media/test_systemplayer.py @@ -64,17 +64,17 @@ class TestSystemPlayer(TestCase): 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 @@ class TestSystemPlayer(TestCase): # 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 @@ class TestSystemPlayer(TestCase): 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 @@ class TestSystemPlayer(TestCase): 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 @@ class TestSystemPlayer(TestCase): # 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 @@ class TestSystemPlayer(TestCase): 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 @@ class TestSystemPlayer(TestCase): 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,14 @@ class TestSystemPlayer(TestCase): 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 +440,7 @@ class TestSystemPlayer(TestCase): 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 +459,7 @@ class TestSystemPlayer(TestCase): # THEN: The info should be correct expected_info = 'This media player uses your operating system to provide media capabilities.
' \ 'Audio
[]
Video
[]
' - 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 +493,9 @@ class TestSystemPlayer(TestCase): 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 +513,7 @@ class TestCheckMediaWorker(TestCase): 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 +530,7 @@ class TestCheckMediaWorker(TestCase): # 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 +547,4 @@ class TestCheckMediaWorker(TestCase): # 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 diff --git a/tests/functional/openlp_core/widgets/test_edits.py b/tests/functional/openlp_core/widgets/test_edits.py index d22558862..0d997c906 100755 --- a/tests/functional/openlp_core/widgets/test_edits.py +++ b/tests/functional/openlp_core/widgets/test_edits.py @@ -27,9 +27,9 @@ from unittest import TestCase 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):