tests: Add noqa markers for setUp/tearDown
This commit is contained in:
parent
a50ba6e3a7
commit
fa8547c397
@ -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'])
|
||||
|
||||
|
||||
@ -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):
|
||||
|
||||
@ -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 = {}
|
||||
|
||||
@ -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],
|
||||
|
||||
@ -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):
|
||||
|
||||
@ -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()
|
||||
|
||||
|
||||
@ -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()
|
||||
|
||||
@ -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):
|
||||
|
||||
@ -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):
|
||||
|
||||
@ -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')]),
|
||||
|
||||
@ -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']
|
||||
|
||||
@ -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):
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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'),
|
||||
|
||||
@ -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):
|
||||
|
||||
@ -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',
|
||||
|
||||
@ -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 = []
|
||||
|
||||
|
||||
@ -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):
|
||||
|
||||
@ -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):
|
||||
|
||||
@ -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):
|
||||
|
||||
@ -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):
|
||||
|
||||
@ -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):
|
||||
|
||||
@ -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):
|
||||
|
||||
@ -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):
|
||||
|
||||
@ -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):
|
||||
|
||||
@ -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'))
|
||||
|
||||
@ -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):
|
||||
|
||||
@ -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):
|
||||
|
||||
@ -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):
|
||||
|
||||
@ -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):
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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):
|
||||
|
||||
@ -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()
|
||||
|
||||
|
||||
|
||||
@ -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):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user