From fa8547c397c0d7eb17fb71997b76e30240d58ed8 Mon Sep 17 00:00:00 2001 From: Thomas Adamcik Date: Tue, 30 Dec 2014 00:01:00 +0100 Subject: [PATCH] tests: Add noqa markers for setUp/tearDown --- tests/audio/test_actor.py | 8 ++++---- tests/audio/test_listener.py | 2 +- tests/audio/test_scan.py | 2 +- tests/audio/test_utils.py | 2 +- tests/backend/test_listener.py | 2 +- tests/config/test_config.py | 2 +- tests/config/test_schemas.py | 2 +- tests/core/test_actor.py | 4 ++-- tests/core/test_events.py | 4 ++-- tests/core/test_history.py | 2 +- tests/core/test_library.py | 2 +- tests/core/test_listener.py | 2 +- tests/core/test_playback.py | 2 +- tests/core/test_playlists.py | 2 +- tests/core/test_tracklist.py | 2 +- tests/local/test_events.py | 4 ++-- tests/local/test_json.py | 2 +- tests/local/test_library.py | 4 ++-- tests/local/test_playback.py | 4 ++-- tests/local/test_playlists.py | 4 ++-- tests/local/test_tracklist.py | 4 ++-- tests/mpd/protocol/__init__.py | 4 ++-- tests/mpd/test_commands.py | 2 +- tests/mpd/test_dispatcher.py | 4 ++-- tests/mpd/test_status.py | 4 ++-- tests/mpd/test_translator.py | 4 ++-- tests/stream/test_library.py | 2 +- tests/test_commands.py | 4 ++-- tests/test_ext.py | 2 +- tests/test_mixer.py | 2 +- tests/utils/network/test_connection.py | 2 +- tests/utils/network/test_lineprotocol.py | 2 +- tests/utils/network/test_server.py | 2 +- tests/utils/test_jsonrpc.py | 4 ++-- tests/utils/test_path.py | 14 +++++++------- 35 files changed, 57 insertions(+), 57 deletions(-) diff --git a/tests/audio/test_actor.py b/tests/audio/test_actor.py index f77505b7..43f7c076 100644 --- a/tests/audio/test_actor.py +++ b/tests/audio/test_actor.py @@ -42,7 +42,7 @@ class BaseTest(unittest.TestCase): audio_class = audio.Audio - def setUp(self): # noqa + def setUp(self): # noqa: N802 config = { 'audio': { 'mixer': 'foomixer', @@ -135,7 +135,7 @@ class AudioDummyTest(DummyMixin, AudioTest): @mock.patch.object(audio.AudioListener, 'send') class AudioEventTest(BaseTest): - def setUp(self): # noqa + def setUp(self): # noqa: N802 super(AudioEventTest, self).setUp() self.audio.enable_sync_handler().get() @@ -461,7 +461,7 @@ class MixerTest(BaseTest): class AudioStateTest(unittest.TestCase): - def setUp(self): # noqa + def setUp(self): # noqa: N802 self.audio = audio.Audio(config=None, mixer=None) def test_state_starts_as_stopped(self): @@ -506,7 +506,7 @@ class AudioStateTest(unittest.TestCase): class AudioBufferingTest(unittest.TestCase): - def setUp(self): # noqa + def setUp(self): # noqa: N802 self.audio = audio.Audio(config=None, mixer=None) self.audio._playbin = mock.Mock(spec=['set_state']) diff --git a/tests/audio/test_listener.py b/tests/audio/test_listener.py index 6b78ecb0..5cac75bb 100644 --- a/tests/audio/test_listener.py +++ b/tests/audio/test_listener.py @@ -8,7 +8,7 @@ from mopidy import audio class AudioListenerTest(unittest.TestCase): - def setUp(self): # noqa + def setUp(self): # noqa: N802 self.listener = audio.AudioListener() def test_on_event_forwards_to_specific_handler(self): diff --git a/tests/audio/test_scan.py b/tests/audio/test_scan.py index 97406c41..50ec8352 100644 --- a/tests/audio/test_scan.py +++ b/tests/audio/test_scan.py @@ -14,7 +14,7 @@ from tests import path_to_data_dir class ScannerTest(unittest.TestCase): - def setUp(self): # noqa + def setUp(self): # noqa: N802 self.errors = {} self.tags = {} self.durations = {} diff --git a/tests/audio/test_utils.py b/tests/audio/test_utils.py index b2028518..f1f15761 100644 --- a/tests/audio/test_utils.py +++ b/tests/audio/test_utils.py @@ -11,7 +11,7 @@ from mopidy.models import Album, Artist, Track # TODO: current test is trying to test everything at once with a complete tags # set, instead we might want to try with a minimal one making testing easier. class TagsToTrackTest(unittest.TestCase): - def setUp(self): # noqa + def setUp(self): # noqa: N802 self.tags = { 'album': ['album'], 'track-number': [1], diff --git a/tests/backend/test_listener.py b/tests/backend/test_listener.py index 6ec39308..ae8bbffe 100644 --- a/tests/backend/test_listener.py +++ b/tests/backend/test_listener.py @@ -8,7 +8,7 @@ from mopidy import backend class BackendListenerTest(unittest.TestCase): - def setUp(self): + def setUp(self): # noqa: N802 self.listener = backend.BackendListener() def test_on_event_forwards_to_specific_handler(self): diff --git a/tests/config/test_config.py b/tests/config/test_config.py index cd97d9a8..b893c5df 100644 --- a/tests/config/test_config.py +++ b/tests/config/test_config.py @@ -84,7 +84,7 @@ class LoadConfigTest(unittest.TestCase): class ValidateTest(unittest.TestCase): - def setUp(self): + def setUp(self): # noqa: N802 self.schema = config.ConfigSchema('foo') self.schema['bar'] = config.ConfigValue() diff --git a/tests/config/test_schemas.py b/tests/config/test_schemas.py index 910b5004..f9e64b9b 100644 --- a/tests/config/test_schemas.py +++ b/tests/config/test_schemas.py @@ -11,7 +11,7 @@ from tests import any_unicode class ConfigSchemaTest(unittest.TestCase): - def setUp(self): + def setUp(self): # noqa: N802 self.schema = schemas.ConfigSchema('test') self.schema['foo'] = mock.Mock() self.schema['bar'] = mock.Mock() diff --git a/tests/core/test_actor.py b/tests/core/test_actor.py index a3cb93da..e82962dc 100644 --- a/tests/core/test_actor.py +++ b/tests/core/test_actor.py @@ -11,7 +11,7 @@ from mopidy.utils import versioning class CoreActorTest(unittest.TestCase): - def setUp(self): + def setUp(self): # noqa: N802 self.backend1 = mock.Mock() self.backend1.uri_schemes.get.return_value = ['dummy1'] self.backend1.actor_ref.actor_class.__name__ = b'B1' @@ -22,7 +22,7 @@ class CoreActorTest(unittest.TestCase): self.core = Core(mixer=None, backends=[self.backend1, self.backend2]) - def tearDown(self): + def tearDown(self): # noqa: N802 pykka.ActorRegistry.stop_all() def test_uri_schemes_has_uris_from_all_backends(self): diff --git a/tests/core/test_events.py b/tests/core/test_events.py index ebe099f3..7226673d 100644 --- a/tests/core/test_events.py +++ b/tests/core/test_events.py @@ -13,11 +13,11 @@ from mopidy.models import Track @mock.patch.object(core.CoreListener, 'send') class BackendEventsTest(unittest.TestCase): - def setUp(self): + def setUp(self): # noqa: N802 self.backend = dummy.create_dummy_backend_proxy() self.core = core.Core.start(backends=[self.backend]).proxy() - def tearDown(self): + def tearDown(self): # noqa: N802 pykka.ActorRegistry.stop_all() def test_forwards_backend_playlists_loaded_event_to_frontends(self, send): diff --git a/tests/core/test_history.py b/tests/core/test_history.py index eb1404b5..42922e52 100644 --- a/tests/core/test_history.py +++ b/tests/core/test_history.py @@ -8,7 +8,7 @@ from mopidy.models import Artist, Track class PlaybackHistoryTest(unittest.TestCase): - def setUp(self): + def setUp(self): # noqa: N802 self.tracks = [ Track(uri='dummy1:a', name='foo', artists=[Artist(name='foober'), Artist(name='barber')]), diff --git a/tests/core/test_library.py b/tests/core/test_library.py index cbbea2e3..9bd3b244 100644 --- a/tests/core/test_library.py +++ b/tests/core/test_library.py @@ -9,7 +9,7 @@ from mopidy.models import Ref, SearchResult, Track class CoreLibraryTest(unittest.TestCase): - def setUp(self): + def setUp(self): # noqa: N802 dummy1_root = Ref.directory(uri='dummy1:directory', name='dummy1') self.backend1 = mock.Mock() self.backend1.uri_schemes.get.return_value = ['dummy1'] diff --git a/tests/core/test_listener.py b/tests/core/test_listener.py index 22bb9146..64003769 100644 --- a/tests/core/test_listener.py +++ b/tests/core/test_listener.py @@ -9,7 +9,7 @@ from mopidy.models import Playlist, TlTrack class CoreListenerTest(unittest.TestCase): - def setUp(self): + def setUp(self): # noqa: N802 self.listener = CoreListener() def test_on_event_forwards_to_specific_handler(self): diff --git a/tests/core/test_playback.py b/tests/core/test_playback.py index 04e3f260..b9d19966 100644 --- a/tests/core/test_playback.py +++ b/tests/core/test_playback.py @@ -9,7 +9,7 @@ from mopidy.models import Track class CorePlaybackTest(unittest.TestCase): - def setUp(self): + def setUp(self): # noqa: N802 self.backend1 = mock.Mock() self.backend1.uri_schemes.get.return_value = ['dummy1'] self.playback1 = mock.Mock(spec=backend.PlaybackProvider) diff --git a/tests/core/test_playlists.py b/tests/core/test_playlists.py index 20577763..55a75767 100644 --- a/tests/core/test_playlists.py +++ b/tests/core/test_playlists.py @@ -9,7 +9,7 @@ from mopidy.models import Playlist, Track class PlaylistsTest(unittest.TestCase): - def setUp(self): + def setUp(self): # noqa: N802 self.backend1 = mock.Mock() self.backend1.uri_schemes.get.return_value = ['dummy1'] self.sp1 = mock.Mock(spec=backend.PlaylistsProvider) diff --git a/tests/core/test_tracklist.py b/tests/core/test_tracklist.py index 38885912..7b5577f9 100644 --- a/tests/core/test_tracklist.py +++ b/tests/core/test_tracklist.py @@ -9,7 +9,7 @@ from mopidy.models import Track class TracklistTest(unittest.TestCase): - def setUp(self): + def setUp(self): # noqa: N802 self.tracks = [ Track(uri='dummy1:a', name='foo'), Track(uri='dummy1:b', name='foo'), diff --git a/tests/local/test_events.py b/tests/local/test_events.py index 7a85731e..ae2ec66a 100644 --- a/tests/local/test_events.py +++ b/tests/local/test_events.py @@ -23,13 +23,13 @@ class LocalBackendEventsTest(unittest.TestCase): } } - def setUp(self): + def setUp(self): # noqa: N802 self.audio = audio.DummyAudio.start().proxy() self.backend = actor.LocalBackend.start( config=self.config, audio=self.audio).proxy() self.core = core.Core.start(backends=[self.backend]).proxy() - def tearDown(self): + def tearDown(self): # noqa: N802 pykka.ActorRegistry.stop_all() def test_playlists_refresh_sends_playlists_loaded_event(self, send): diff --git a/tests/local/test_json.py b/tests/local/test_json.py index 2da13632..0d62c2e3 100644 --- a/tests/local/test_json.py +++ b/tests/local/test_json.py @@ -9,7 +9,7 @@ from mopidy.models import Ref class BrowseCacheTest(unittest.TestCase): maxDiff = None - def setUp(self): + def setUp(self): # noqa: N802 self.uris = ['local:track:foo/bar/song1', 'local:track:foo/bar/song2', 'local:track:foo/baz/song3', diff --git a/tests/local/test_library.py b/tests/local/test_library.py index 3be41333..6cc1992e 100644 --- a/tests/local/test_library.py +++ b/tests/local/test_library.py @@ -73,14 +73,14 @@ class LocalLibraryProviderTest(unittest.TestCase): }, } - def setUp(self): + def setUp(self): # noqa: N802 actor.LocalBackend.libraries = [json.JsonLibrary] self.backend = actor.LocalBackend.start( config=self.config, audio=None).proxy() self.core = core.Core(backends=[self.backend]) self.library = self.core.library - def tearDown(self): + def tearDown(self): # noqa: N802 pykka.ActorRegistry.stop_all() actor.LocalBackend.libraries = [] diff --git a/tests/local/test_playback.py b/tests/local/test_playback.py index ae031191..0edd89c5 100644 --- a/tests/local/test_playback.py +++ b/tests/local/test_playback.py @@ -39,7 +39,7 @@ class LocalPlaybackProviderTest(unittest.TestCase): track = Track(uri=uri, length=4464) self.tracklist.add([track]) - def setUp(self): + def setUp(self): # noqa: N802 self.audio = audio.DummyAudio.start().proxy() self.backend = actor.LocalBackend.start( config=self.config, audio=self.audio).proxy() @@ -52,7 +52,7 @@ class LocalPlaybackProviderTest(unittest.TestCase): assert self.tracks[0].length >= 2000, \ 'First song needs to be at least 2000 miliseconds' - def tearDown(self): + def tearDown(self): # noqa: N802 pykka.ActorRegistry.stop_all() def test_uri_scheme(self): diff --git a/tests/local/test_playlists.py b/tests/local/test_playlists.py index 4210f248..c9aa299a 100644 --- a/tests/local/test_playlists.py +++ b/tests/local/test_playlists.py @@ -25,7 +25,7 @@ class LocalPlaylistsProviderTest(unittest.TestCase): } } - def setUp(self): + def setUp(self): # noqa: N802 self.config['local']['playlists_dir'] = tempfile.mkdtemp() self.playlists_dir = self.config['local']['playlists_dir'] @@ -34,7 +34,7 @@ class LocalPlaylistsProviderTest(unittest.TestCase): config=self.config, audio=self.audio).proxy() self.core = core.Core(backends=[self.backend]) - def tearDown(self): + def tearDown(self): # noqa: N802 pykka.ActorRegistry.stop_all() if os.path.exists(self.playlists_dir): diff --git a/tests/local/test_tracklist.py b/tests/local/test_tracklist.py index 69dd6400..d74d436c 100644 --- a/tests/local/test_tracklist.py +++ b/tests/local/test_tracklist.py @@ -26,7 +26,7 @@ class LocalTracklistProviderTest(unittest.TestCase): tracks = [ Track(uri=generate_song(i), length=4464) for i in range(1, 4)] - def setUp(self): + def setUp(self): # noqa: N802 self.audio = audio.DummyAudio.start().proxy() self.backend = actor.LocalBackend.start( config=self.config, audio=self.audio).proxy() @@ -36,7 +36,7 @@ class LocalTracklistProviderTest(unittest.TestCase): assert len(self.tracks) == 3, 'Need three tracks to run tests.' - def tearDown(self): + def tearDown(self): # noqa: N802 pykka.ActorRegistry.stop_all() def test_length(self): diff --git a/tests/mpd/protocol/__init__.py b/tests/mpd/protocol/__init__.py index b9600a1d..4f6e697a 100644 --- a/tests/mpd/protocol/__init__.py +++ b/tests/mpd/protocol/__init__.py @@ -31,7 +31,7 @@ class BaseTestCase(unittest.TestCase): } } - def setUp(self): + def setUp(self): # noqa: N802 self.backend = dummy.create_dummy_backend_proxy() self.core = core.Core.start(backends=[self.backend]).proxy() @@ -41,7 +41,7 @@ class BaseTestCase(unittest.TestCase): self.dispatcher = self.session.dispatcher self.context = self.dispatcher.context - def tearDown(self): + def tearDown(self): # noqa: N802 pykka.ActorRegistry.stop_all() def sendRequest(self, request): diff --git a/tests/mpd/test_commands.py b/tests/mpd/test_commands.py index 4699dfe0..e0903e9f 100644 --- a/tests/mpd/test_commands.py +++ b/tests/mpd/test_commands.py @@ -55,7 +55,7 @@ class TestConverts(unittest.TestCase): class TestCommands(unittest.TestCase): - def setUp(self): + def setUp(self): # noqa: N802 self.commands = protocol.Commands() def test_add_as_a_decorator(self): diff --git a/tests/mpd/test_dispatcher.py b/tests/mpd/test_dispatcher.py index 24d03bf1..1a230451 100644 --- a/tests/mpd/test_dispatcher.py +++ b/tests/mpd/test_dispatcher.py @@ -11,7 +11,7 @@ from mopidy.mpd.exceptions import MpdAckError class MpdDispatcherTest(unittest.TestCase): - def setUp(self): + def setUp(self): # noqa: N802 config = { 'mpd': { 'password': None, @@ -21,7 +21,7 @@ class MpdDispatcherTest(unittest.TestCase): self.core = core.Core.start(backends=[self.backend]).proxy() self.dispatcher = MpdDispatcher(config=config) - def tearDown(self): + def tearDown(self): # noqa: N802 pykka.ActorRegistry.stop_all() def test_call_handler_for_unknown_command_raises_exception(self): diff --git a/tests/mpd/test_status.py b/tests/mpd/test_status.py index 57b2d4d4..1015615c 100644 --- a/tests/mpd/test_status.py +++ b/tests/mpd/test_status.py @@ -20,13 +20,13 @@ STOPPED = PlaybackState.STOPPED class StatusHandlerTest(unittest.TestCase): - def setUp(self): + def setUp(self): # noqa: N802 self.backend = dummy.create_dummy_backend_proxy() self.core = core.Core.start(backends=[self.backend]).proxy() self.dispatcher = dispatcher.MpdDispatcher(core=self.core) self.context = self.dispatcher.context - def tearDown(self): + def tearDown(self): # noqa: N802 pykka.ActorRegistry.stop_all() def test_stats_method(self): diff --git a/tests/mpd/test_translator.py b/tests/mpd/test_translator.py index 82e60d93..027ce28f 100644 --- a/tests/mpd/test_translator.py +++ b/tests/mpd/test_translator.py @@ -26,11 +26,11 @@ class TrackMpdFormatTest(unittest.TestCase): length=137000, ) - def setUp(self): + def setUp(self): # noqa: N802 self.media_dir = '/dir/subdir' mtime.set_fake_time(1234567) - def tearDown(self): + def tearDown(self): # noqa: N802 mtime.undo_fake() def test_track_to_mpd_format_for_empty_track(self): diff --git a/tests/stream/test_library.py b/tests/stream/test_library.py index b660a2d4..7ed871cb 100644 --- a/tests/stream/test_library.py +++ b/tests/stream/test_library.py @@ -19,7 +19,7 @@ from tests import path_to_data_dir class LibraryProviderTest(unittest.TestCase): - def setUp(self): # noqa: ignore method must be lowercase + def setUp(self): # noqa: N802 self.backend = mock.Mock() self.backend.uri_schemes = ['file'] self.uri = path_to_uri(path_to_data_dir('song1.wav')) diff --git a/tests/test_commands.py b/tests/test_commands.py index 58f681be..0942b3a0 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -44,12 +44,12 @@ class ConfigOverrideTypeTest(unittest.TestCase): class CommandParsingTest(unittest.TestCase): - def setUp(self): + def setUp(self): # noqa: N802 self.exit_patcher = mock.patch.object(commands.Command, 'exit') self.exit_mock = self.exit_patcher.start() self.exit_mock.side_effect = SystemExit - def tearDown(self): + def tearDown(self): # noqa: N802 self.exit_patcher.stop() def test_command_parsing_returns_namespace(self): diff --git a/tests/test_ext.py b/tests/test_ext.py index 0e850e60..f4e247b6 100644 --- a/tests/test_ext.py +++ b/tests/test_ext.py @@ -6,7 +6,7 @@ from mopidy import config, ext class ExtensionTest(unittest.TestCase): - def setUp(self): + def setUp(self): # noqa: N802 self.ext = ext.Extension() def test_dist_name_is_none(self): diff --git a/tests/test_mixer.py b/tests/test_mixer.py index d0f1b0f2..c57d861a 100644 --- a/tests/test_mixer.py +++ b/tests/test_mixer.py @@ -8,7 +8,7 @@ from mopidy import mixer class MixerListenerTest(unittest.TestCase): - def setUp(self): + def setUp(self): # noqa: N802 self.listener = mixer.MixerListener() def test_on_event_forwards_to_specific_handler(self): diff --git a/tests/utils/network/test_connection.py b/tests/utils/network/test_connection.py index 031ea385..0ccaea0a 100644 --- a/tests/utils/network/test_connection.py +++ b/tests/utils/network/test_connection.py @@ -17,7 +17,7 @@ from tests import any_int, any_unicode class ConnectionTest(unittest.TestCase): - def setUp(self): + def setUp(self): # noqa: N802 self.mock = Mock(spec=network.Connection) def test_init_ensure_nonblocking_io(self): diff --git a/tests/utils/network/test_lineprotocol.py b/tests/utils/network/test_lineprotocol.py index 28bfbad2..1b584e47 100644 --- a/tests/utils/network/test_lineprotocol.py +++ b/tests/utils/network/test_lineprotocol.py @@ -14,7 +14,7 @@ from tests import any_unicode class LineProtocolTest(unittest.TestCase): - def setUp(self): + def setUp(self): # noqa: N802 self.mock = Mock(spec=network.LineProtocol) self.mock.terminator = network.LineProtocol.terminator diff --git a/tests/utils/network/test_server.py b/tests/utils/network/test_server.py index f5f61101..d85d6c27 100644 --- a/tests/utils/network/test_server.py +++ b/tests/utils/network/test_server.py @@ -14,7 +14,7 @@ from tests import any_int class ServerTest(unittest.TestCase): - def setUp(self): + def setUp(self): # noqa: N802 self.mock = Mock(spec=network.Server) def test_init_calls_create_server_socket(self): diff --git a/tests/utils/test_jsonrpc.py b/tests/utils/test_jsonrpc.py index bf7da541..a74000b2 100644 --- a/tests/utils/test_jsonrpc.py +++ b/tests/utils/test_jsonrpc.py @@ -40,7 +40,7 @@ class Calculator(object): class JsonRpcTestBase(unittest.TestCase): - def setUp(self): + def setUp(self): # noqa: N802 self.backend = dummy.create_dummy_backend_proxy() self.core = core.Core.start(backends=[self.backend]).proxy() @@ -56,7 +56,7 @@ class JsonRpcTestBase(unittest.TestCase): encoders=[models.ModelJSONEncoder], decoders=[models.model_json_decoder]) - def tearDown(self): + def tearDown(self): # noqa: N802 pykka.ActorRegistry.stop_all() diff --git a/tests/utils/test_path.py b/tests/utils/test_path.py index 36d1f7db..6fd4f8d1 100644 --- a/tests/utils/test_path.py +++ b/tests/utils/test_path.py @@ -16,10 +16,10 @@ import tests class GetOrCreateDirTest(unittest.TestCase): - def setUp(self): + def setUp(self): # noqa: N802 self.parent = tempfile.mkdtemp() - def tearDown(self): + def tearDown(self): # noqa: N802 if os.path.isdir(self.parent): shutil.rmtree(self.parent) @@ -67,10 +67,10 @@ class GetOrCreateDirTest(unittest.TestCase): class GetOrCreateFileTest(unittest.TestCase): - def setUp(self): + def setUp(self): # noqa: N802 self.parent = tempfile.mkdtemp() - def tearDown(self): + def tearDown(self): # noqa: N802 if os.path.isdir(self.parent): shutil.rmtree(self.parent) @@ -221,10 +221,10 @@ class ExpandPathTest(unittest.TestCase): class FindMTimesTest(unittest.TestCase): maxDiff = None - def setUp(self): + def setUp(self): # noqa: N802 self.tmpdir = tempfile.mkdtemp(b'.mopidy-tests') - def tearDown(self): + def tearDown(self): # noqa: N802 shutil.rmtree(self.tmpdir, ignore_errors=True) def mkdir(self, *args): @@ -378,7 +378,7 @@ class FindMTimesTest(unittest.TestCase): # TODO: kill this in favour of just os.path.getmtime + mocks class MtimeTest(unittest.TestCase): - def tearDown(self): + def tearDown(self): # noqa: N802 path.mtime.undo_fake() def test_mtime_of_current_dir(self):