tests: Make tests warning safe

This commit is contained in:
Thomas Adamcik 2015-03-26 21:58:44 +01:00
parent b9d7ea37be
commit b31f0c421f
8 changed files with 43 additions and 23 deletions

View File

@ -1,6 +1,7 @@
from __future__ import absolute_import, unicode_literals
import unittest
import warnings
import mock
@ -16,7 +17,10 @@ from tests import dummy_backend
class BackendEventsTest(unittest.TestCase):
def setUp(self): # noqa: N802
self.backend = dummy_backend.create_proxy()
self.core = core.Core.start(backends=[self.backend]).proxy()
with warnings.catch_warnings():
warnings.simplefilter('ignore')
self.core = core.Core.start(backends=[self.backend]).proxy()
def tearDown(self): # noqa: N802
pykka.ActorRegistry.stop_all()

View File

@ -1,6 +1,7 @@
from __future__ import absolute_import, unicode_literals
import unittest
import warnings
import mock
@ -40,8 +41,11 @@ class BaseTestCase(unittest.TestCase):
else:
self.mixer = None
self.backend = dummy_backend.create_proxy()
self.core = core.Core.start(
mixer=self.mixer, backends=[self.backend]).proxy()
with warnings.catch_warnings():
warnings.simplefilter('ignore')
self.core = core.Core.start(
mixer=self.mixer, backends=[self.backend]).proxy()
self.uri_map = uri_mapper.MpdUriMapper(self.core)
self.connection = MockConnection()

View File

@ -1,5 +1,7 @@
from __future__ import absolute_import, unicode_literals
import warnings
from mopidy.models import Ref, Track
from tests.mpd import protocol
@ -247,7 +249,10 @@ class CurrentPlaylistHandlerTest(protocol.BaseTestCase):
'ACK [50@0] {moveid} No such song')
def test_playlist_returns_same_as_playlistinfo(self):
playlist_response = self.send_request('playlist')
with warnings.catch_warnings():
warnings.filterwarnings('ignore', message='.*playlistinfo.*')
playlist_response = self.send_request('playlist')
playlistinfo_response = self.send_request('playlistinfo')
self.assertEqual(playlist_response, playlistinfo_response)

View File

@ -1,6 +1,7 @@
from __future__ import absolute_import, unicode_literals
import unittest
import warnings
from mopidy.core import PlaybackState
from mopidy.models import Track
@ -200,13 +201,15 @@ class PlaybackControlHandlerTest(protocol.BaseTestCase):
self.assertEqual(PLAYING, self.core.playback.state.get())
self.assertInResponse('OK')
self.send_request('pause')
self.assertEqual(PAUSED, self.core.playback.state.get())
self.assertInResponse('OK')
with warnings.catch_warnings():
warnings.filterwarnings('ignore', message='.*pause command w/o.*')
self.send_request('pause')
self.assertEqual(PAUSED, self.core.playback.state.get())
self.assertInResponse('OK')
self.send_request('pause')
self.assertEqual(PLAYING, self.core.playback.state.get())
self.assertInResponse('OK')
self.send_request('pause')
self.assertEqual(PLAYING, self.core.playback.state.get())
self.assertInResponse('OK')
def test_play_without_pos(self):
self.core.tracklist.add([Track(uri='dummy:a')])

View File

@ -1,6 +1,7 @@
from __future__ import absolute_import, unicode_literals
import unittest
import warnings
import pykka
@ -20,9 +21,12 @@ class MpdDispatcherTest(unittest.TestCase):
}
}
self.backend = dummy_backend.create_proxy()
self.core = core.Core.start(backends=[self.backend]).proxy()
self.dispatcher = MpdDispatcher(config=config)
with warnings.catch_warnings():
warnings.simplefilter('ignore')
self.core = core.Core.start(backends=[self.backend]).proxy()
def tearDown(self): # noqa: N802
pykka.ActorRegistry.stop_all()

View File

@ -8,15 +8,6 @@ from mopidy.mpd.exceptions import (
class MpdExceptionsTest(unittest.TestCase):
def test_key_error_wrapped_in_mpd_ack_error(self):
try:
try:
raise KeyError('Track X not found')
except KeyError as e:
raise MpdAckError(e.message)
except MpdAckError as e:
self.assertEqual(e.message, 'Track X not found')
def test_mpd_not_implemented_is_a_mpd_ack_error(self):
try:
raise MpdNotImplemented

View File

@ -1,6 +1,7 @@
from __future__ import absolute_import, unicode_literals
import unittest
import warnings
import pykka
@ -25,8 +26,12 @@ class StatusHandlerTest(unittest.TestCase):
def setUp(self): # noqa: N802
self.mixer = dummy_mixer.create_proxy()
self.backend = dummy_backend.create_proxy()
self.core = core.Core.start(
mixer=self.mixer, backends=[self.backend]).proxy()
with warnings.catch_warnings():
warnings.simplefilter('ignore')
self.core = core.Core.start(
mixer=self.mixer, backends=[self.backend]).proxy()
self.dispatcher = dispatcher.MpdDispatcher(core=self.core)
self.context = self.dispatcher.context

View File

@ -2,6 +2,7 @@ from __future__ import absolute_import, unicode_literals
import json
import unittest
import warnings
import mock
@ -52,9 +53,12 @@ class Calculator(object):
class JsonRpcTestBase(unittest.TestCase):
def setUp(self): # noqa: N802
self.backend = dummy_backend.create_proxy()
self.core = core.Core.start(backends=[self.backend]).proxy()
self.calc = Calculator()
with warnings.catch_warnings():
warnings.simplefilter('ignore')
self.core = core.Core.start(backends=[self.backend]).proxy()
self.jrw = jsonrpc.JsonRpcWrapper(
objects={
'hello': lambda: 'Hello, world!',