tests: Convert to using deprecation helpers across the board.
This commit is contained in:
parent
bd1e822fea
commit
9ede14f4a1
@ -1,7 +1,6 @@
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
import unittest
|
||||
import warnings
|
||||
|
||||
import mock
|
||||
|
||||
@ -9,6 +8,7 @@ import pykka
|
||||
|
||||
from mopidy import core
|
||||
from mopidy.models import Track
|
||||
from mopidy.utils import deprecation
|
||||
|
||||
from tests import dummy_backend
|
||||
|
||||
@ -20,8 +20,7 @@ class BackendEventsTest(unittest.TestCase):
|
||||
self.backend.library.dummy_library = [
|
||||
Track(uri='dummy:a'), Track(uri='dummy:b')]
|
||||
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter('ignore')
|
||||
with deprecation.ignore():
|
||||
self.core = core.Core.start(backends=[self.backend]).proxy()
|
||||
|
||||
def tearDown(self): # noqa: N802
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
import unittest
|
||||
import warnings
|
||||
|
||||
import mock
|
||||
|
||||
from mopidy import backend, core
|
||||
from mopidy.models import Image, Ref, SearchResult, Track
|
||||
from mopidy.utils import deprecation
|
||||
|
||||
|
||||
class BaseCoreLibraryTest(unittest.TestCase):
|
||||
@ -273,15 +273,9 @@ class CoreLibraryTest(BaseCoreLibraryTest):
|
||||
|
||||
|
||||
class DeprecatedFindExactCoreLibraryTest(BaseCoreLibraryTest):
|
||||
def setUp(self): # noqa: N802
|
||||
super(DeprecatedFindExactCoreLibraryTest, self).setUp()
|
||||
self._warnings_filters = warnings.filters
|
||||
warnings.filters = warnings.filters[:]
|
||||
warnings.filterwarnings('ignore', '.*library.find_exact.*')
|
||||
|
||||
def tearDown(self): # noqa: N802
|
||||
super(DeprecatedFindExactCoreLibraryTest, self).tearDown()
|
||||
warnings.filters = self._warnings_filters
|
||||
def run(self, result=None):
|
||||
with deprecation.ignore('core.library.find_exact'):
|
||||
return super(DeprecatedFindExactCoreLibraryTest, self).run(result)
|
||||
|
||||
def test_find_exact_combines_results_from_all_backends(self):
|
||||
track1 = Track(uri='dummy1:a')
|
||||
@ -360,15 +354,9 @@ class DeprecatedFindExactCoreLibraryTest(BaseCoreLibraryTest):
|
||||
|
||||
|
||||
class DeprecatedLookupCoreLibraryTest(BaseCoreLibraryTest):
|
||||
def setUp(self): # noqa: N802
|
||||
super(DeprecatedLookupCoreLibraryTest, self).setUp()
|
||||
self._warnings_filters = warnings.filters
|
||||
warnings.filters = warnings.filters[:]
|
||||
warnings.filterwarnings('ignore', 'library.lookup.*"uri" argument.*')
|
||||
|
||||
def tearDown(self): # noqa: N802
|
||||
super(DeprecatedLookupCoreLibraryTest, self).tearDown()
|
||||
warnings.filters = self._warnings_filters
|
||||
def run(self, result=None):
|
||||
with deprecation.ignore('core.library.lookup:uri_arg'):
|
||||
return super(DeprecatedLookupCoreLibraryTest, self).run(result)
|
||||
|
||||
def test_lookup_selects_dummy1_backend(self):
|
||||
self.core.library.lookup('dummy1:a')
|
||||
@ -391,6 +379,10 @@ class DeprecatedLookupCoreLibraryTest(BaseCoreLibraryTest):
|
||||
|
||||
|
||||
class LegacyFindExactToSearchLibraryTest(unittest.TestCase):
|
||||
def run(self, result=None):
|
||||
with deprecation.ignore('core.library.find_exact'):
|
||||
return super(LegacyFindExactToSearchLibraryTest, self).run(result)
|
||||
|
||||
def setUp(self): # noqa: N802
|
||||
self.backend = mock.Mock()
|
||||
self.backend.actor_ref.actor_class.__name__ = 'DummyBackend'
|
||||
@ -398,18 +390,8 @@ class LegacyFindExactToSearchLibraryTest(unittest.TestCase):
|
||||
self.backend.library = mock.Mock(spec=backend.LibraryProvider)
|
||||
self.core = core.Core(mixer=None, backends=[self.backend])
|
||||
|
||||
self._warnings_filters = warnings.filters
|
||||
warnings.filters = warnings.filters[:]
|
||||
warnings.filterwarnings('ignore', '.*library.find_exact.*')
|
||||
|
||||
def tearDown(self): # noqa: N802
|
||||
warnings.filters = self._warnings_filters
|
||||
|
||||
def test_core_find_exact_calls_backend_search_with_exact(self):
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter('ignore')
|
||||
self.core.library.find_exact(query={'any': ['a']})
|
||||
|
||||
self.core.library.find_exact(query={'any': ['a']})
|
||||
self.backend.library.search.assert_called_once_with(
|
||||
query=dict(any=['a']), uris=None, exact=True)
|
||||
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
import unittest
|
||||
import warnings
|
||||
|
||||
import mock
|
||||
|
||||
from mopidy import backend, core
|
||||
from mopidy.models import Playlist, Ref, Track
|
||||
from mopidy.utils import deprecation
|
||||
|
||||
|
||||
class BasePlaylistsTest(unittest.TestCase):
|
||||
@ -231,16 +231,10 @@ class PlaylistTest(BasePlaylistsTest):
|
||||
|
||||
|
||||
class DeprecatedFilterPlaylistsTest(BasePlaylistsTest):
|
||||
def setUp(self): # noqa: N802
|
||||
super(DeprecatedFilterPlaylistsTest, self).setUp()
|
||||
self._warnings_filters = warnings.filters
|
||||
warnings.filters = warnings.filters[:]
|
||||
warnings.filterwarnings('ignore', '.*filter.*')
|
||||
warnings.filterwarnings('ignore', '.*get_playlists.*')
|
||||
|
||||
def tearDown(self): # noqa: N802
|
||||
super(DeprecatedFilterPlaylistsTest, self).tearDown()
|
||||
warnings.filters = self._warnings_filters
|
||||
def run(self, result=None):
|
||||
with deprecation.ignore(ids=['core.playlists.filter',
|
||||
'core.playlists.get_playlists']):
|
||||
return super(DeprecatedFilterPlaylistsTest, self).run(result)
|
||||
|
||||
def test_filter_returns_matching_playlists(self):
|
||||
result = self.core.playlists.filter(name='A')
|
||||
@ -254,15 +248,9 @@ class DeprecatedFilterPlaylistsTest(BasePlaylistsTest):
|
||||
|
||||
|
||||
class DeprecatedGetPlaylistsTest(BasePlaylistsTest):
|
||||
def setUp(self): # noqa: N802
|
||||
super(DeprecatedGetPlaylistsTest, self).setUp()
|
||||
self._warnings_filters = warnings.filters
|
||||
warnings.filters = warnings.filters[:]
|
||||
warnings.filterwarnings('ignore', '.*get_playlists.*')
|
||||
|
||||
def tearDown(self): # noqa: N802
|
||||
super(DeprecatedGetPlaylistsTest, self).tearDown()
|
||||
warnings.filters = self._warnings_filters
|
||||
def run(self, result=None):
|
||||
with deprecation.ignore('core.playlists.get_playlists'):
|
||||
return super(DeprecatedGetPlaylistsTest, self).run(result)
|
||||
|
||||
def test_get_playlists_combines_result_from_backends(self):
|
||||
result = self.core.playlists.get_playlists()
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
import unittest
|
||||
import warnings
|
||||
|
||||
import mock
|
||||
|
||||
from mopidy import backend, core
|
||||
from mopidy.models import Track
|
||||
from mopidy.utils import deprecation
|
||||
|
||||
|
||||
class TracklistTest(unittest.TestCase):
|
||||
@ -36,8 +36,7 @@ class TracklistTest(unittest.TestCase):
|
||||
self.library.lookup.reset_mock()
|
||||
self.core.tracklist.clear()
|
||||
|
||||
with warnings.catch_warnings():
|
||||
warnings.filterwarnings('ignore', r'tracklist.add.*"uri".*')
|
||||
with deprecation.ignore('core.tracklist.add:uri_arg'):
|
||||
tl_tracks = self.core.tracklist.add(uris=['dummy1:a'])
|
||||
|
||||
self.library.lookup.assert_called_once_with('dummy1:a')
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
import warnings
|
||||
from mopidy.utils import deprecation
|
||||
|
||||
|
||||
def generate_song(i):
|
||||
@ -9,8 +9,7 @@ def generate_song(i):
|
||||
|
||||
def populate_tracklist(func):
|
||||
def wrapper(self):
|
||||
with warnings.catch_warnings():
|
||||
warnings.filterwarnings('ignore', 'tracklist.add.*"tracks".*')
|
||||
with deprecation.ignore('core.tracklist.add:tracks_arg'):
|
||||
self.tl_tracks = self.core.tracklist.add(self.tracks)
|
||||
return func(self)
|
||||
|
||||
|
||||
@ -2,7 +2,6 @@ from __future__ import absolute_import, unicode_literals
|
||||
|
||||
import time
|
||||
import unittest
|
||||
import warnings
|
||||
|
||||
import mock
|
||||
|
||||
@ -12,6 +11,7 @@ from mopidy import core
|
||||
from mopidy.core import PlaybackState
|
||||
from mopidy.local import actor
|
||||
from mopidy.models import Track
|
||||
from mopidy.utils import deprecation
|
||||
|
||||
from tests import dummy_audio, path_to_data_dir
|
||||
from tests.local import generate_song, populate_tracklist
|
||||
@ -43,6 +43,10 @@ class LocalPlaybackProviderTest(unittest.TestCase):
|
||||
def trigger_end_of_track(self):
|
||||
self.playback._on_end_of_track()
|
||||
|
||||
def run(self, result=None):
|
||||
with deprecation.ignore('core.tracklist.add:tracks_arg'):
|
||||
return super(LocalPlaybackProviderTest, self).run(result)
|
||||
|
||||
def setUp(self): # noqa: N802
|
||||
self.audio = dummy_audio.create_proxy()
|
||||
self.backend = actor.LocalBackend.start(
|
||||
@ -56,13 +60,8 @@ class LocalPlaybackProviderTest(unittest.TestCase):
|
||||
assert self.tracks[0].length >= 2000, \
|
||||
'First song needs to be at least 2000 miliseconds'
|
||||
|
||||
self._warnings_filters = warnings.filters
|
||||
warnings.filters = warnings.filters[:]
|
||||
warnings.filterwarnings('ignore', 'tracklist.add.*"tracks".*')
|
||||
|
||||
def tearDown(self): # noqa: N802
|
||||
pykka.ActorRegistry.stop_all()
|
||||
warnings.filters = self._warnings_filters
|
||||
|
||||
def test_uri_scheme(self):
|
||||
self.assertNotIn('file', self.core.uri_schemes)
|
||||
|
||||
@ -2,7 +2,6 @@ from __future__ import absolute_import, unicode_literals
|
||||
|
||||
import random
|
||||
import unittest
|
||||
import warnings
|
||||
|
||||
import pykka
|
||||
|
||||
@ -10,6 +9,7 @@ from mopidy import core
|
||||
from mopidy.core import PlaybackState
|
||||
from mopidy.local import actor
|
||||
from mopidy.models import Playlist, TlTrack, Track
|
||||
from mopidy.utils import deprecation
|
||||
|
||||
from tests import dummy_audio, path_to_data_dir
|
||||
from tests.local import generate_song, populate_tracklist
|
||||
@ -27,6 +27,10 @@ class LocalTracklistProviderTest(unittest.TestCase):
|
||||
tracks = [
|
||||
Track(uri=generate_song(i), length=4464) for i in range(1, 4)]
|
||||
|
||||
def run(self, result=None):
|
||||
with deprecation.ignore('core.tracklist.add:tracks_arg'):
|
||||
return super(LocalTracklistProviderTest, self).run(result)
|
||||
|
||||
def setUp(self): # noqa: N802
|
||||
self.audio = dummy_audio.create_proxy()
|
||||
self.backend = actor.LocalBackend.start(
|
||||
@ -37,13 +41,8 @@ class LocalTracklistProviderTest(unittest.TestCase):
|
||||
|
||||
assert len(self.tracks) == 3, 'Need three tracks to run tests.'
|
||||
|
||||
self._warnings_filters = warnings.filters
|
||||
warnings.filters = warnings.filters[:]
|
||||
warnings.filterwarnings('ignore', 'tracklist.add.*"tracks".*')
|
||||
|
||||
def tearDown(self): # noqa: N802
|
||||
pykka.ActorRegistry.stop_all()
|
||||
warnings.filters = self._warnings_filters
|
||||
|
||||
def test_length(self):
|
||||
self.assertEqual(0, len(self.controller.tl_tracks))
|
||||
|
||||
@ -4,7 +4,6 @@ import os
|
||||
import shutil
|
||||
import tempfile
|
||||
import unittest
|
||||
import warnings
|
||||
|
||||
import pykka
|
||||
|
||||
@ -12,6 +11,7 @@ from mopidy import core
|
||||
from mopidy.m3u import actor
|
||||
from mopidy.m3u.translator import playlist_uri_to_path
|
||||
from mopidy.models import Playlist, Track
|
||||
from mopidy.utils import deprecation
|
||||
|
||||
from tests import dummy_audio, path_to_data_dir
|
||||
from tests.m3u import generate_song
|
||||
@ -272,16 +272,10 @@ class M3UPlaylistsProviderTest(unittest.TestCase):
|
||||
|
||||
|
||||
class DeprecatedM3UPlaylistsProviderTest(M3UPlaylistsProviderTest):
|
||||
def setUp(self): # noqa: N802
|
||||
super(DeprecatedM3UPlaylistsProviderTest, self).setUp()
|
||||
self._warnings_filters = warnings.filters
|
||||
warnings.filters = warnings.filters[:]
|
||||
warnings.filterwarnings('ignore', '.*filter.*')
|
||||
warnings.filterwarnings('ignore', '.*get_playlists.*')
|
||||
|
||||
def tearDown(self): # noqa: N802
|
||||
super(DeprecatedM3UPlaylistsProviderTest, self).tearDown()
|
||||
warnings.filters = self._warnings_filters
|
||||
def run(self, result=None):
|
||||
with deprecation.ignore(ids=['core.playlists.filter',
|
||||
'core.playlists.get_playlists']):
|
||||
return super(DeprecatedM3UPlaylistsProviderTest, self).run(result)
|
||||
|
||||
def test_filter_without_criteria(self):
|
||||
self.assertEqual(self.core.playlists.get_playlists(),
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
import unittest
|
||||
import warnings
|
||||
|
||||
import mock
|
||||
|
||||
@ -9,6 +8,7 @@ import pykka
|
||||
|
||||
from mopidy import core
|
||||
from mopidy.mpd import session, uri_mapper
|
||||
from mopidy.utils import deprecation
|
||||
|
||||
from tests import dummy_backend, dummy_mixer
|
||||
|
||||
@ -42,8 +42,7 @@ class BaseTestCase(unittest.TestCase):
|
||||
self.mixer = None
|
||||
self.backend = dummy_backend.create_proxy()
|
||||
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter('ignore')
|
||||
with deprecation.ignore():
|
||||
self.core = core.Core.start(
|
||||
mixer=self.mixer, backends=[self.backend]).proxy()
|
||||
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
import warnings
|
||||
|
||||
from mopidy.models import Ref, Track
|
||||
from mopidy.utils import deprecation
|
||||
|
||||
from tests.mpd import protocol
|
||||
|
||||
@ -233,8 +232,7 @@ class PlaylistIdCommandTest(BasePopulatedTracklistTestCase):
|
||||
|
||||
class PlaylistInfoCommandTest(BasePopulatedTracklistTestCase):
|
||||
def test_playlist_returns_same_as_playlistinfo(self):
|
||||
with warnings.catch_warnings():
|
||||
warnings.filterwarnings('ignore', message='.*playlistinfo.*')
|
||||
with deprecation.ignore('mpd.protocol.current_playlist.playlist'):
|
||||
playlist_response = self.send_request('playlist')
|
||||
|
||||
playlistinfo_response = self.send_request('playlistinfo')
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
import unittest
|
||||
import warnings
|
||||
|
||||
from mopidy.core import PlaybackState
|
||||
from mopidy.models import Track
|
||||
from mopidy.utils import deprecation
|
||||
|
||||
from tests.mpd import protocol
|
||||
|
||||
@ -203,8 +203,7 @@ class PlaybackControlHandlerTest(protocol.BaseTestCase):
|
||||
self.assertEqual(PLAYING, self.core.playback.state.get())
|
||||
self.assertInResponse('OK')
|
||||
|
||||
with warnings.catch_warnings():
|
||||
warnings.filterwarnings('ignore', message='.*pause command w/o.*')
|
||||
with deprecation.ignore('mpd.protocol.playback.pause:state_arg'):
|
||||
self.send_request('pause')
|
||||
self.assertEqual(PAUSED, self.core.playback.state.get())
|
||||
self.assertInResponse('OK')
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
import unittest
|
||||
import warnings
|
||||
|
||||
import pykka
|
||||
|
||||
from mopidy import core
|
||||
from mopidy.mpd.dispatcher import MpdDispatcher
|
||||
from mopidy.mpd.exceptions import MpdAckError
|
||||
from mopidy.utils import deprecation
|
||||
|
||||
from tests import dummy_backend
|
||||
|
||||
@ -23,8 +23,7 @@ class MpdDispatcherTest(unittest.TestCase):
|
||||
self.backend = dummy_backend.create_proxy()
|
||||
self.dispatcher = MpdDispatcher(config=config)
|
||||
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter('ignore')
|
||||
with deprecation.ignore():
|
||||
self.core = core.Core.start(backends=[self.backend]).proxy()
|
||||
|
||||
def tearDown(self): # noqa: N802
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
import unittest
|
||||
import warnings
|
||||
|
||||
import pykka
|
||||
|
||||
@ -10,6 +9,7 @@ from mopidy.core import PlaybackState
|
||||
from mopidy.models import Track
|
||||
from mopidy.mpd import dispatcher
|
||||
from mopidy.mpd.protocol import status
|
||||
from mopidy.utils import deprecation
|
||||
|
||||
from tests import dummy_backend, dummy_mixer
|
||||
|
||||
@ -27,8 +27,7 @@ class StatusHandlerTest(unittest.TestCase):
|
||||
self.mixer = dummy_mixer.create_proxy()
|
||||
self.backend = dummy_backend.create_proxy()
|
||||
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter('ignore')
|
||||
with deprecation.ignore():
|
||||
self.core = core.Core.start(
|
||||
mixer=self.mixer, backends=[self.backend]).proxy()
|
||||
|
||||
|
||||
@ -2,14 +2,13 @@ from __future__ import absolute_import, unicode_literals
|
||||
|
||||
import json
|
||||
import unittest
|
||||
import warnings
|
||||
|
||||
import mock
|
||||
|
||||
import pykka
|
||||
|
||||
from mopidy import core, models
|
||||
from mopidy.utils import jsonrpc
|
||||
from mopidy.utils import deprecation, jsonrpc
|
||||
|
||||
from tests import dummy_backend
|
||||
|
||||
@ -55,8 +54,7 @@ class JsonRpcTestBase(unittest.TestCase):
|
||||
self.backend = dummy_backend.create_proxy()
|
||||
self.calc = Calculator()
|
||||
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter('ignore')
|
||||
with deprecation.ignore():
|
||||
self.core = core.Core.start(backends=[self.backend]).proxy()
|
||||
|
||||
self.jrw = jsonrpc.JsonRpcWrapper(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user