Merge pull request #130 from adamcik/feature/unittest2-fallback

This commit is contained in:
Stein Magnus Jodal 2011-08-01 04:33:53 -07:00
commit aa8f60fb86
48 changed files with 182 additions and 144 deletions

View File

@ -60,6 +60,7 @@ def find_files(path):
yield filename
# pylint: enable = W0612
# FIXME replace with mock usage in tests.
class Mtime(object):
def __init__(self):
self.fake = None

View File

@ -1,27 +1,24 @@
import os
import sys
try: # 2.7
# pylint: disable = E0611,F0401
from unittest.case import SkipTest
# pylint: enable = E0611,F0401
except ImportError:
try: # Nose
from nose.plugins.skip import SkipTest
except ImportError: # Failsafe
class SkipTest(Exception):
pass
if sys.version_info < (2, 7):
import unittest2 as unittest
else:
import unittest
from mopidy import settings
# Nuke any local settings to ensure same test env all over
settings.local.clear()
def path_to_data_dir(name):
path = os.path.dirname(__file__)
path = os.path.join(path, 'data')
path = os.path.abspath(path)
return os.path.join(path, name)
class IsA(object):
def __init__(self, klass):
self.klass = klass
@ -38,6 +35,7 @@ class IsA(object):
def __repr__(self):
return str(self.klass)
any_int = IsA(int)
any_str = IsA(str)
any_unicode = IsA(unicode)

View File

@ -1,5 +1,4 @@
import mock
import multiprocessing
import random
from mopidy.models import Playlist, Track
@ -7,6 +6,7 @@ from mopidy.gstreamer import GStreamer
from tests.backends.base import populate_playlist
class CurrentPlaylistControllerTest(object):
tracks = []

View File

@ -1,6 +1,7 @@
from mopidy.models import Playlist, Track, Album, Artist
from tests import SkipTest, path_to_data_dir
from tests import unittest, path_to_data_dir
class LibraryControllerTest(object):
artists = [Artist(name='artist1'), Artist(name='artist2'), Artist()]
@ -20,11 +21,13 @@ class LibraryControllerTest(object):
def test_refresh(self):
self.library.refresh()
@unittest.SkipTest
def test_refresh_uri(self):
raise SkipTest
pass
@unittest.SkipTest
def test_refresh_missing_uri(self):
raise SkipTest
pass
def test_lookup(self):
track = self.library.lookup(self.tracks[0].uri)

View File

@ -1,16 +1,16 @@
import mock
import multiprocessing
import random
import time
from mopidy.models import Track
from mopidy.gstreamer import GStreamer
from tests import SkipTest
from tests import unittest
from tests.backends.base import populate_playlist
# TODO Test 'playlist repeat', e.g. repeat=1,single=0
class PlaybackControllerTest(object):
tracks = []
@ -520,7 +520,7 @@ class PlaybackControllerTest(object):
self.assert_(wrapper.called)
@SkipTest # Blocks for 10ms
@unittest.SkipTest # Blocks for 10ms
@populate_playlist
def test_end_of_track_callback_gets_called(self):
self.playback.play()
@ -599,7 +599,7 @@ class PlaybackControllerTest(object):
self.playback.pause()
self.assertEqual(self.playback.resume(), None)
@SkipTest # Uses sleep and might not work with LocalBackend
@unittest.SkipTest # Uses sleep and might not work with LocalBackend
@populate_playlist
def test_resume_continues_from_right_position(self):
self.playback.play()
@ -668,7 +668,7 @@ class PlaybackControllerTest(object):
self.playback.seek(0)
self.assertEqual(self.playback.state, self.playback.PLAYING)
@SkipTest
@unittest.SkipTest
@populate_playlist
def test_seek_beyond_end_of_song(self):
# FIXME need to decide return value
@ -688,7 +688,7 @@ class PlaybackControllerTest(object):
self.playback.seek(self.current_playlist.tracks[-1].length * 100)
self.assertEqual(self.playback.state, self.playback.STOPPED)
@SkipTest
@unittest.SkipTest
@populate_playlist
def test_seek_beyond_start_of_song(self):
# FIXME need to decide return value
@ -741,7 +741,7 @@ class PlaybackControllerTest(object):
self.assertEqual(self.playback.time_position, 0)
@SkipTest # Uses sleep and does might not work with LocalBackend
@unittest.SkipTest # Uses sleep and does might not work with LocalBackend
@populate_playlist
def test_time_position_when_playing(self):
self.playback.play()
@ -750,7 +750,7 @@ class PlaybackControllerTest(object):
second = self.playback.time_position
self.assert_(second > first, '%s - %s' % (first, second))
@SkipTest # Uses sleep
@unittest.SkipTest # Uses sleep
@populate_playlist
def test_time_position_when_paused(self):
self.playback.play()

View File

@ -5,7 +5,8 @@ import tempfile
from mopidy import settings
from mopidy.models import Playlist
from tests import SkipTest, path_to_data_dir
from tests import unittest, path_to_data_dir
class StoredPlaylistsControllerTest(object):
def setUp(self):
@ -78,11 +79,13 @@ class StoredPlaylistsControllerTest(object):
except LookupError as e:
self.assertEqual(u'"name=c" match no playlists', e[0])
@unittest.SkipTest
def test_lookup(self):
raise SkipTest
pass
@unittest.SkipTest
def test_refresh(self):
raise SkipTest
pass
def test_rename(self):
playlist = self.stored.create('test')
@ -100,5 +103,6 @@ class StoredPlaylistsControllerTest(object):
self.stored.save(playlist)
self.assert_(playlist in self.stored.playlists)
@unittest.SkipTest
def test_playlist_with_unknown_track(self):
raise SkipTest
pass

View File

@ -1,5 +1,4 @@
import mock
import unittest
from pykka.registry import ActorRegistry
@ -7,6 +6,9 @@ from mopidy.backends.dummy import DummyBackend
from mopidy.listeners import BackendListener
from mopidy.models import Track
from tests import unittest
@mock.patch.object(BackendListener, 'send')
class BackendEventsTest(unittest.TestCase):
def setUp(self):

View File

@ -1,18 +1,16 @@
import unittest
# FIXME Our Windows build server does not support GStreamer yet
import sys
if sys.platform == 'win32':
from tests import SkipTest
raise SkipTest
from mopidy import settings
from mopidy.backends.local import LocalBackend
from mopidy.models import Track
from tests import unittest
from tests.backends.base.current_playlist import CurrentPlaylistControllerTest
from tests.backends.local import generate_song
@unittest.skipIf(sys.platform == 'win32',
'Our Windows build server does not support GStreamer yet')
class LocalCurrentPlaylistControllerTest(CurrentPlaylistControllerTest,
unittest.TestCase):

View File

@ -1,17 +1,14 @@
import unittest
# FIXME Our Windows build server does not support GStreamer yet
import sys
if sys.platform == 'win32':
from tests import SkipTest
raise SkipTest
from mopidy import settings
from mopidy.backends.local import LocalBackend
from tests import path_to_data_dir
from tests import unittest, path_to_data_dir
from tests.backends.base.library import LibraryControllerTest
@unittest.skipIf(sys.platform == 'win32',
'Our Windows build server does not support GStreamer yet')
class LocalLibraryControllerTest(LibraryControllerTest, unittest.TestCase):
backend_class = LocalBackend

View File

@ -1,20 +1,17 @@
import unittest
# FIXME Our Windows build server does not support GStreamer yet
import sys
if sys.platform == 'win32':
from tests import SkipTest
raise SkipTest
from mopidy import settings
from mopidy.backends.local import LocalBackend
from mopidy.models import Track
from mopidy.utils.path import path_to_uri
from tests import path_to_data_dir
from tests import unittest, path_to_data_dir
from tests.backends.base.playback import PlaybackControllerTest
from tests.backends.local import generate_song
@unittest.skipIf(sys.platform == 'win32',
'Our Windows build server does not support GStreamer yet')
class LocalPlaybackControllerTest(PlaybackControllerTest, unittest.TestCase):
backend_class = LocalBackend
tracks = [Track(uri=generate_song(i), length=4464)

View File

@ -1,24 +1,19 @@
import unittest
import os
from tests import SkipTest
# FIXME Our Windows build server does not support GStreamer yet
import sys
if sys.platform == 'win32':
raise SkipTest
from mopidy import settings
from mopidy.backends.local import LocalBackend
from mopidy.mixers.dummy import DummyMixer
from mopidy.models import Playlist, Track
from mopidy.utils.path import path_to_uri
from tests import path_to_data_dir
from tests.backends.base.stored_playlists import \
StoredPlaylistsControllerTest
from tests import unittest, path_to_data_dir
from tests.backends.base.stored_playlists import (
StoredPlaylistsControllerTest)
from tests.backends.local import generate_song
@unittest.skipIf(sys.platform == 'win32',
'Our Windows build server does not support GStreamer yet')
class LocalStoredPlaylistsControllerTest(StoredPlaylistsControllerTest,
unittest.TestCase):
@ -77,14 +72,18 @@ class LocalStoredPlaylistsControllerTest(StoredPlaylistsControllerTest,
self.assertEqual('test', self.stored.playlists[0].name)
self.assertEqual(track.uri, self.stored.playlists[0].tracks[0].uri)
@unittest.SkipTest
def test_santitising_of_playlist_filenames(self):
raise SkipTest
pass
@unittest.SkipTest
def test_playlist_folder_is_createad(self):
raise SkipTest
pass
@unittest.SkipTest
def test_create_sets_playlist_uri(self):
raise SkipTest
pass
@unittest.SkipTest
def test_save_sets_playlist_uri(self):
raise SkipTest
pass

View File

@ -2,13 +2,12 @@
import os
import tempfile
import unittest
from mopidy.utils.path import path_to_uri
from mopidy.backends.local.translator import parse_m3u, parse_mpd_tag_cache
from mopidy.models import Track, Artist, Album
from tests import SkipTest, path_to_data_dir
from tests import unittest, path_to_data_dir
song1_path = path_to_data_dir('song1.mp3')
song2_path = path_to_data_dir('song2.mp3')
@ -17,6 +16,9 @@ song1_uri = path_to_uri(song1_path)
song2_uri = path_to_uri(song2_path)
encoded_uri = path_to_uri(encoded_path)
# FIXME use mock instead of tempfile.NamedTemporaryFile
class M3UToUriTest(unittest.TestCase):
def test_empty_file(self):
uris = parse_m3u(path_to_data_dir('empty.m3u'))
@ -127,9 +129,10 @@ class MPDTagCacheToTracksTest(unittest.TestCase):
self.assertEqual(track, list(tracks)[0])
@unittest.SkipTest
def test_misencoded_cache(self):
# FIXME not sure if this can happen
raise SkipTest
pass
def test_cache_with_blank_track_info(self):
tracks = parse_mpd_tag_cache(path_to_data_dir('blank_tag_cache'),

View File

@ -1,11 +1,12 @@
import unittest
from mopidy.backends.dummy import DummyBackend
from mopidy.frontends.mpd.dispatcher import MpdDispatcher
from mopidy.frontends.mpd.exceptions import MpdAckError
from mopidy.frontends.mpd.protocol import request_handlers, handle_request
from mopidy.mixers.dummy import DummyMixer
from tests import unittest
class MpdDispatcherTest(unittest.TestCase):
def setUp(self):
self.backend = DummyBackend.start().proxy()

View File

@ -1,8 +1,9 @@
import unittest
from mopidy.frontends.mpd.exceptions import (MpdAckError, MpdPermissionError,
MpdUnknownCommand, MpdSystemError, MpdNotImplemented)
from tests import unittest
class MpdExceptionsTest(unittest.TestCase):
def test_key_error_wrapped_in_mpd_ack_error(self):
try:

View File

@ -1,4 +1,3 @@
import unittest
import mock
from mopidy import settings
@ -6,6 +5,8 @@ from mopidy.backends import dummy as backend
from mopidy.frontends import mpd
from mopidy.mixers import dummy as mixer
from tests import unittest
class MockConnetion(mock.Mock):
def __init__(self, *args, **kwargs):

View File

@ -1,5 +1,6 @@
from tests.frontends.mpd import protocol
class AudioOutputHandlerTest(protocol.BaseTestCase):
def test_enableoutput(self):
self.sendRequest(u'enableoutput "0"')

View File

@ -2,6 +2,7 @@ from mopidy import settings
from tests.frontends.mpd import protocol
class AuthenticationTest(protocol.BaseTestCase):
def test_authentication_with_valid_password_is_accepted(self):
settings.MPD_SERVER_PASSWORD = u'topsecret'

View File

@ -1,5 +1,6 @@
from tests.frontends.mpd import protocol
class CommandListsTest(protocol.BaseTestCase):
def test_command_list_begin(self):
response = self.sendRequest(u'command_list_begin')

View File

@ -4,6 +4,7 @@ from mopidy import settings
from tests.frontends.mpd import protocol
class ConnectionHandlerTest(protocol.BaseTestCase):
def test_close_closes_the_client_connection(self):
with patch.object(self.session, 'close') as close_mock:

View File

@ -2,6 +2,7 @@ from mopidy.models import Track
from tests.frontends.mpd import protocol
class CurrentPlaylistHandlerTest(protocol.BaseTestCase):
def test_add(self):
needle = Track(uri='dummy://foo')

View File

@ -1,10 +1,10 @@
from mock import patch
from mopidy.frontends.mpd.protocol.status import SUBSYSTEMS
from mopidy.models import Track
from tests.frontends.mpd import protocol
class IdleHandlerTest(protocol.BaseTestCase):
def idleEvent(self, subsystem):
self.session.on_idle(subsystem)

View File

@ -1,5 +1,6 @@
from tests.frontends.mpd import protocol
class MusicDatabaseHandlerTest(protocol.BaseTestCase):
def test_count(self):
self.sendRequest(u'count "tag" "needle"')

View File

@ -1,7 +1,7 @@
from mopidy.backends import base as backend
from mopidy.models import Track
from tests import SkipTest
from tests import unittest
from tests.frontends.mpd import protocol
PAUSED = backend.PlaybackController.PAUSED
@ -146,14 +146,17 @@ class PlaybackOptionsHandlerTest(protocol.BaseTestCase):
self.assertInResponse(u'OK')
self.assertInResponse(u'off')
@unittest.SkipTest
def test_replay_gain_status_off(self):
raise SkipTest # TODO
pass
@unittest.SkipTest
def test_replay_gain_status_track(self):
raise SkipTest # TODO
pass
@unittest.SkipTest
def test_replay_gain_status_album(self):
raise SkipTest # TODO
pass
class PlaybackControlHandlerTest(protocol.BaseTestCase):

View File

@ -2,6 +2,7 @@ from mopidy import settings
from tests.frontends.mpd import protocol
class ReflectionHandlerTest(protocol.BaseTestCase):
def test_commands_returns_list_of_all_commands(self):
self.sendRequest(u'commands')

View File

@ -4,6 +4,7 @@ from mopidy.models import Track
from tests.frontends.mpd import protocol
class IssueGH17RegressionTest(protocol.BaseTestCase):
"""
The issue: http://github.com/mopidy/mopidy/issues#issue/17

View File

@ -2,6 +2,7 @@ from mopidy.models import Track
from tests.frontends.mpd import protocol
class StatusHandlerTest(protocol.BaseTestCase):
def test_clearerror(self):
self.sendRequest(u'clearerror')

View File

@ -1,5 +1,6 @@
from tests.frontends.mpd import protocol
class StickersHandlerTest(protocol.BaseTestCase):
def test_sticker_get(self):
self.sendRequest(

View File

@ -1,9 +1,10 @@
import datetime as dt
import datetime
from mopidy.models import Track, Playlist
from tests.frontends.mpd import protocol
class StoredPlaylistsHandlerTest(protocol.BaseTestCase):
def test_listplaylist(self):
self.backend.stored_playlists.playlists = [
@ -33,7 +34,7 @@ class StoredPlaylistsHandlerTest(protocol.BaseTestCase):
u'ACK [50@0] {listplaylistinfo} No such playlist')
def test_listplaylists(self):
last_modified = dt.datetime(2001, 3, 17, 13, 41, 17, 12345)
last_modified = datetime.datetime(2001, 3, 17, 13, 41, 17, 12345)
self.backend.stored_playlists.playlists = [Playlist(name='a',
last_modified=last_modified)]

View File

@ -1,12 +1,14 @@
import datetime as dt
import datetime
import os
import unittest
from mopidy import settings
from mopidy.utils.path import mtime, uri_to_path
from mopidy.frontends.mpd import translator, protocol
from mopidy.models import Album, Artist, Playlist, Track
from tests import unittest
class TrackMpdFormatTest(unittest.TestCase):
track = Track(
uri=u'a uri',
@ -15,7 +17,7 @@ class TrackMpdFormatTest(unittest.TestCase):
album=Album(name=u'an album', num_tracks=13,
artists=[Artist(name=u'an other artist')]),
track_no=7,
date=dt.date(1977, 1, 1),
date=datetime.date(1977, 1, 1),
length=137000,
)
@ -61,7 +63,7 @@ class TrackMpdFormatTest(unittest.TestCase):
self.assert_(('Album', 'an album') in result)
self.assert_(('AlbumArtist', 'an other artist') in result)
self.assert_(('Track', '7/13') in result)
self.assert_(('Date', dt.date(1977, 1, 1)) in result)
self.assert_(('Date', datetime.date(1977, 1, 1)) in result)
self.assert_(('Pos', 9) in result)
self.assert_(('Id', 122) in result)
self.assertEqual(len(result), 10)

View File

@ -1,11 +1,11 @@
import unittest
from mopidy.backends import dummy as backend
from mopidy.frontends.mpd import dispatcher
from mopidy.frontends.mpd.protocol import status
from mopidy.mixers import dummy as mixer
from mopidy.models import Track
from tests import unittest
PAUSED = backend.PlaybackController.PAUSED
PLAYING = backend.PlaybackController.PLAYING
STOPPED = backend.PlaybackController.STOPPED
@ -13,6 +13,7 @@ STOPPED = backend.PlaybackController.STOPPED
# FIXME migrate to using protocol.BaseTestCase instead of status.stats
# directly?
class StatusHandlerTest(unittest.TestCase):
def setUp(self):
self.backend = backend.DummyBackend.start().proxy()

View File

@ -1,9 +1,11 @@
import mock
import unittest
from mopidy.frontends.mpris import MprisFrontend, objects
from mopidy.models import Track
from tests import unittest
class BackendEventsTest(unittest.TestCase):
def setUp(self):
self.mpris_frontend = MprisFrontend() # As a plain class, not an actor

View File

@ -1,5 +1,4 @@
import mock
import unittest
from mopidy.backends.dummy import DummyBackend
from mopidy.backends.base.playback import PlaybackController
@ -7,10 +6,13 @@ from mopidy.frontends.mpris import objects
from mopidy.mixers.dummy import DummyMixer
from mopidy.models import Album, Artist, Track
from tests import unittest
PLAYING = PlaybackController.PLAYING
PAUSED = PlaybackController.PAUSED
STOPPED = PlaybackController.STOPPED
class PlayerInterfaceTest(unittest.TestCase):
def setUp(self):
objects.MprisObject._connect_to_dbus = mock.Mock()

View File

@ -1,10 +1,12 @@
import mock
import unittest
from mopidy import settings
from mopidy.backends.dummy import DummyBackend
from mopidy.frontends.mpris import objects
from tests import unittest
class RootInterfaceTest(unittest.TestCase):
def setUp(self):
objects.exit_process = mock.Mock()

View File

@ -1,21 +1,16 @@
import multiprocessing
import unittest
from tests import SkipTest
# FIXME Our Windows build server does not support GStreamer yet
import sys
if sys.platform == 'win32':
raise SkipTest
from mopidy import settings
from mopidy.gstreamer import GStreamer
from mopidy.utils.path import path_to_uri
from tests import path_to_data_dir
from tests import unittest, path_to_data_dir
# TODO BaseOutputTest?
@unittest.skipIf(sys.platform == 'win32',
'Our Windows build server does not support GStreamer yet')
class GStreamerTest(unittest.TestCase):
def setUp(self):
settings.BACKENDS = ('mopidy.backends.local.LocalBackend',)
@ -48,11 +43,11 @@ class GStreamerTest(unittest.TestCase):
self.gstreamer.start_playback()
self.assertTrue(self.gstreamer.stop_playback())
@SkipTest
@unittest.SkipTest
def test_deliver_data(self):
pass # TODO
@SkipTest
@unittest.SkipTest
def test_end_of_data_stream(self):
pass # TODO
@ -71,10 +66,10 @@ class GStreamerTest(unittest.TestCase):
self.assertTrue(self.gstreamer.set_volume(100))
self.assertEqual(100, self.gstreamer.get_volume())
@SkipTest
@unittest.SkipTest
def test_set_state_encapsulation(self):
pass # TODO
@SkipTest
@unittest.SkipTest
def test_set_position(self):
pass # TODO

View File

@ -1,10 +1,12 @@
import os
import subprocess
import sys
import unittest
import mopidy
from tests import unittest
class HelpTest(unittest.TestCase):
def test_help_has_mopidy_options(self):
mopidy_dir = os.path.dirname(mopidy.__file__)

View File

@ -1,8 +1,9 @@
import unittest
from mopidy.listeners import BackendListener
from mopidy.models import Track
from tests import unittest
class BackendListenerTest(unittest.TestCase):
def setUp(self):
self.listener = BackendListener()

View File

@ -1,8 +1,9 @@
import unittest
from mopidy.mixers.denon import DenonMixer
from tests.mixers.base_test import BaseMixerTest
from tests import unittest
class DenonMixerDeviceMock(object):
def __init__(self):
self._open = True
@ -24,6 +25,7 @@ class DenonMixerDeviceMock(object):
def open(self):
self._open = True
class DenonMixerTest(BaseMixerTest, unittest.TestCase):
ACTUAL_MAX = 99
INITIAL = 1

View File

@ -1,8 +1,9 @@
import unittest
from mopidy.mixers.dummy import DummyMixer
from tests import unittest
from tests.mixers.base_test import BaseMixerTest
class DenonMixerTest(BaseMixerTest, unittest.TestCase):
mixer_class = DummyMixer

View File

@ -1,9 +1,9 @@
import datetime as dt
import unittest
import datetime
from mopidy.models import Artist, Album, CpTrack, Track, Playlist
from tests import SkipTest
from tests import unittest
class GenericCopyTets(unittest.TestCase):
def compare(self, orig, other):
@ -49,6 +49,7 @@ class GenericCopyTets(unittest.TestCase):
test = lambda: Track().copy(invalid_key=True)
self.assertRaises(TypeError, test)
class ArtistTest(unittest.TestCase):
def test_uri(self):
uri = u'an_uri'
@ -321,7 +322,7 @@ class TrackTest(unittest.TestCase):
self.assertRaises(AttributeError, setattr, track, 'track_no', None)
def test_date(self):
date = dt.date(1977, 1, 1)
date = datetime.date(1977, 1, 1)
track = Track(date=date)
self.assertEqual(track.date, date)
self.assertRaises(AttributeError, setattr, track, 'date', None)
@ -400,7 +401,7 @@ class TrackTest(unittest.TestCase):
self.assertEqual(hash(track1), hash(track2))
def test_eq_date(self):
date = dt.date.today()
date = datetime.date.today()
track1 = Track(date=date)
track2 = Track(date=date)
self.assertEqual(track1, track2)
@ -425,7 +426,7 @@ class TrackTest(unittest.TestCase):
self.assertEqual(hash(track1), hash(track2))
def test_eq(self):
date = dt.date.today()
date = datetime.date.today()
artists = [Artist()]
album = Album()
track1 = Track(uri=u'uri', name=u'name', artists=artists, album=album,
@ -474,8 +475,8 @@ class TrackTest(unittest.TestCase):
self.assertNotEqual(hash(track1), hash(track2))
def test_ne_date(self):
track1 = Track(date=dt.date.today())
track2 = Track(date=dt.date.today()-dt.timedelta(days=1))
track1 = Track(date=datetime.date.today())
track2 = Track(date=datetime.date.today()-datetime.timedelta(days=1))
self.assertNotEqual(track1, track2)
self.assertNotEqual(hash(track1), hash(track2))
@ -500,11 +501,11 @@ class TrackTest(unittest.TestCase):
def test_ne(self):
track1 = Track(uri=u'uri1', name=u'name1',
artists=[Artist(name=u'name1')], album=Album(name=u'name1'),
track_no=1, date=dt.date.today(), length=100, bitrate=100,
track_no=1, date=datetime.date.today(), length=100, bitrate=100,
musicbrainz_id='id1')
track2 = Track(uri=u'uri2', name=u'name2',
artists=[Artist(name=u'name2')], album=Album(name=u'name2'),
track_no=2, date=dt.date.today()-dt.timedelta(days=1),
track_no=2, date=datetime.date.today()-datetime.timedelta(days=1),
length=200, bitrate=200, musicbrainz_id='id2')
self.assertNotEqual(track1, track2)
self.assertNotEqual(hash(track1), hash(track2))
@ -535,7 +536,7 @@ class PlaylistTest(unittest.TestCase):
self.assertEqual(playlist.length, 3)
def test_last_modified(self):
last_modified = dt.datetime.now()
last_modified = datetime.datetime.now()
playlist = Playlist(last_modified=last_modified)
self.assertEqual(playlist.last_modified, last_modified)
self.assertRaises(AttributeError, setattr, playlist, 'last_modified',
@ -543,7 +544,7 @@ class PlaylistTest(unittest.TestCase):
def test_with_new_uri(self):
tracks = [Track()]
last_modified = dt.datetime.now()
last_modified = datetime.datetime.now()
playlist = Playlist(uri=u'an uri', name=u'a name', tracks=tracks,
last_modified=last_modified)
new_playlist = playlist.copy(uri=u'another uri')
@ -554,7 +555,7 @@ class PlaylistTest(unittest.TestCase):
def test_with_new_name(self):
tracks = [Track()]
last_modified = dt.datetime.now()
last_modified = datetime.datetime.now()
playlist = Playlist(uri=u'an uri', name=u'a name', tracks=tracks,
last_modified=last_modified)
new_playlist = playlist.copy(name=u'another name')
@ -565,7 +566,7 @@ class PlaylistTest(unittest.TestCase):
def test_with_new_tracks(self):
tracks = [Track()]
last_modified = dt.datetime.now()
last_modified = datetime.datetime.now()
playlist = Playlist(uri=u'an uri', name=u'a name', tracks=tracks,
last_modified=last_modified)
new_tracks = [Track(), Track()]
@ -577,8 +578,8 @@ class PlaylistTest(unittest.TestCase):
def test_with_new_last_modified(self):
tracks = [Track()]
last_modified = dt.datetime.now()
new_last_modified = last_modified + dt.timedelta(1)
last_modified = datetime.datetime.now()
new_last_modified = last_modified + datetime.timedelta(1)
playlist = Playlist(uri=u'an uri', name=u'a name', tracks=tracks,
last_modified=last_modified)
new_playlist = playlist.copy(last_modified=new_last_modified)

View File

@ -1,10 +1,10 @@
import unittest
from datetime import date
from mopidy.scanner import Scanner, translator
from mopidy.models import Track, Artist, Album
from tests import path_to_data_dir, SkipTest
from tests import unittest, path_to_data_dir
class FakeGstDate(object):
def __init__(self, year, month, day):
@ -12,6 +12,7 @@ class FakeGstDate(object):
self.month = month
self.day = day
class TranslatorTest(unittest.TestCase):
def setUp(self):
self.data = {
@ -126,6 +127,7 @@ class TranslatorTest(unittest.TestCase):
del self.track['date']
self.check()
class ScannerTest(unittest.TestCase):
def setUp(self):
self.errors = {}
@ -185,6 +187,6 @@ class ScannerTest(unittest.TestCase):
self.scan('scanner/image')
self.assert_(self.errors)
@SkipTest
@unittest.SkipTest
def test_song_without_time_is_handeled(self):
pass

View File

@ -1,7 +1,8 @@
import unittest
from mopidy.utils import get_class
from tests import unittest
class GetClassTest(unittest.TestCase):
def test_loading_module_that_does_not_exist(self):
self.assertRaises(ImportError, get_class, 'foo.bar.Baz')

View File

@ -3,12 +3,12 @@ import gobject
import logging
import pykka
import socket
import unittest
from mock import patch, sentinel, Mock
from mopidy.utils import network
from mock import patch, sentinel, Mock
from tests import any_int, any_unicode, SkipTest
from tests import unittest, any_int, any_unicode
class ConnectionTest(unittest.TestCase):
def setUp(self):

View File

@ -1,11 +1,12 @@
#encoding: utf-8
import re
import unittest
from mock import sentinel, Mock
from mopidy.utils import network
from mock import sentinel, Mock
from tests import unittest
class LineProtocolTest(unittest.TestCase):
def setUp(self):

View File

@ -1,12 +1,12 @@
import errno
import gobject
import socket
import unittest
from mock import patch, sentinel, Mock
from mopidy.utils import network
from mock import patch, sentinel, Mock
from tests import any_int
from tests import unittest, any_int
class ServerTest(unittest.TestCase):
def setUp(self):

View File

@ -1,10 +1,10 @@
import socket
import unittest
from mock import patch, Mock
from mopidy.utils import network
from mock import patch, Mock
from tests import SkipTest
from tests import unittest
class FormatHostnameTest(unittest.TestCase):
@patch('mopidy.utils.network.has_ipv6', True)
@ -52,6 +52,6 @@ class CreateSocketTest(unittest.TestCase):
self.assertEqual(socket_mock.call_args[0],
(socket.AF_INET6, socket.SOCK_STREAM))
@SkipTest
@unittest.SkipTest
def test_ipv6_only_is_set(self):
pass

View File

@ -4,12 +4,12 @@ import os
import shutil
import sys
import tempfile
import unittest
from mopidy.utils.path import (get_or_create_folder, mtime,
path_to_uri, uri_to_path, split_path, find_files)
from tests import path_to_data_dir
from tests import unittest, path_to_data_dir
class GetOrCreateFolderTest(unittest.TestCase):
def setUp(self):

View File

@ -1,10 +1,12 @@
import os
import unittest
from mopidy import settings as default_settings_module, SettingsError
from mopidy.utils.settings import (format_settings_list, mask_value_if_secret,
SettingsProxy, validate_settings)
from tests import unittest
class ValidateSettingsTest(unittest.TestCase):
def setUp(self):
self.defaults = {

View File

@ -1,8 +1,10 @@
from distutils.version import StrictVersion as SV
import unittest
import platform
from mopidy import get_version, get_plain_version, get_platform, get_python
from mopidy import get_plain_version, get_platform, get_python
from tests import unittest
class VersionTest(unittest.TestCase):
def test_current_version_is_parsable_as_a_strict_version_number(self):