diff --git a/.gitignore b/.gitignore index c4b78634..cc090815 100644 --- a/.gitignore +++ b/.gitignore @@ -4,8 +4,10 @@ .idea MANIFEST build/ +cover/ dist/ docs/_build/ +nosetests.xml pip-log.txt src/ tmp/ diff --git a/docs/development/contributing.rst b/docs/development/contributing.rst index 2889c210..f3d68e6d 100644 --- a/docs/development/contributing.rst +++ b/docs/development/contributing.rst @@ -44,20 +44,22 @@ style guidelines, with a couple of notable exceptions: Running tests ============= -To run tests, you need a couple of dependencies. Some can be installed through +To run tests, you need a couple of dependencies. They can be installed through Debian/Ubuntu package management:: - sudo aptitude install python-coverage + sudo aptitude install python-coverage python-nose -The rest (or all dependencies if you want to) can be installed using pip:: +Or, they can be installed using ``pip``:: - sudo aptitude install python-pip python-setuptools bzr sudo pip install -r requirements-tests.txt -Then, to run all tests:: +Then, to run all tests, go to the project directory and run:: python tests +For more documentation on testing Mopidy, check out the `nose docs +`_. + Writing documentation ===================== @@ -66,15 +68,10 @@ To write documentation, we use `Sphinx `_. See their site for lots of documentation on how to use Sphinx. To generate HTML or LaTeX from the documentation files, you need some additional dependencies. -You can either install them through Debian/Ubuntu package management:: +You can install them through Debian/Ubuntu package management:: sudo aptitude install python-sphinx python-pygraphviz graphviz -Or, install them using pip:: - - sudo aptitude install python-pip python-setuptools graphviz - sudo pip install -r requirements-docs.txt - Then, to generate docs:: cd docs/ diff --git a/mopidy/backends/despotify.py b/mopidy/backends/despotify.py index 6757a285..ea0404dc 100644 --- a/mopidy/backends/despotify.py +++ b/mopidy/backends/despotify.py @@ -32,9 +32,10 @@ class DespotifyBackend(BaseBackend): - r503: Segfaults when looking up playlists, both your own lists and other peoples shared lists. To reproduce:: - >>> import spytify - >>> s = spytify.Spytify('alice', 'secret') + >>> import spytify # doctest: +SKIP + >>> s = spytify.Spytify('alice', 'secret') # doctest: +SKIP >>> s.lookup('spotify:user:klette:playlist:5rOGYPwwKqbAcVX8bW4k5V') + ... # doctest: +SKIP Segmentation fault """ diff --git a/requirements-tests.txt b/requirements-tests.txt index 0342fb1c..33f49451 100644 --- a/requirements-tests.txt +++ b/requirements-tests.txt @@ -1,2 +1,2 @@ coverage --e bzr+http://liw.iki.fi/bzr/coverage-test-runner/trunk/#egg=CoverageTestRunner +nose diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 00000000..c0e68566 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,8 @@ +[nosetests] +verbosity = 1 +with-doctest = 1 +with-coverage = 1 +cover-package = mopidy +cover-inclusive = 1 +cover-html = 1 +with-xunit = 1 diff --git a/tests/__main__.py b/tests/__main__.py index 54ad93a9..e2bb3e72 100644 --- a/tests/__main__.py +++ b/tests/__main__.py @@ -1,19 +1,4 @@ -import logging -import os -import sys - -from CoverageTestRunner import CoverageTestRunner - -def main(): - logging.basicConfig(level=logging.CRITICAL) - sys.path.insert(0, - os.path.abspath(os.path.join(os.path.dirname(__file__), '../'))) - r = CoverageTestRunner() - r.add_pair('mopidy/mixers/dummy.py', 'tests/mixers/dummytest.py') - r.add_pair('mopidy/mixers/denon.py', 'tests/mixers/denontest.py') - r.add_pair('mopidy/models.py', 'tests/modelstest.py') - r.add_pair('mopidy/mpd/frontend.py', 'tests/mpd/frontendtest.py') - r.run() +import nose if __name__ == '__main__': - main() + nose.main() diff --git a/tests/backends/__init__.py b/tests/backends/__init__.py index d91467dd..e69de29b 100644 --- a/tests/backends/__init__.py +++ b/tests/backends/__init__.py @@ -1,46 +0,0 @@ -class BaseCurrentPlaylistControllerTest(object): - uris = [] - backend_class = None - - def setUp(self): - self.backend = self.backend_class() - - def test_add(self): - playlist = self.backend.current_playlist - - for uri in self.uris: - playlist.add(uri) - self.assertEqual(uri, playlist.tracks[-1].uri) - - def test_add_at_position(self): - playlist = self.backend.current_playlist - - for uri in self.uris: - playlist.add(uri, 0) - self.assertEqual(uri, playlist.tracks[0].uri) - - # FIXME test other placements - -class BasePlaybackControllerTest(object): - backend_class = None - - def setUp(self): - self.backend = self.backend_class() - - def test_play(self): - playback = self.backend.playback - - self.assertEqual(playback.state, playback.STOPPED) - - playback.play() - - self.assertEqual(playback.state, playback.PLAYING) - - def test_next(self): - playback = self.backend.playback - - current_song = playback.playlist_position - - playback.next() - - self.assertEqual(playback.playlist_position, current_song+1) diff --git a/tests/backends/base_test.py b/tests/backends/base_test.py new file mode 100644 index 00000000..d91467dd --- /dev/null +++ b/tests/backends/base_test.py @@ -0,0 +1,46 @@ +class BaseCurrentPlaylistControllerTest(object): + uris = [] + backend_class = None + + def setUp(self): + self.backend = self.backend_class() + + def test_add(self): + playlist = self.backend.current_playlist + + for uri in self.uris: + playlist.add(uri) + self.assertEqual(uri, playlist.tracks[-1].uri) + + def test_add_at_position(self): + playlist = self.backend.current_playlist + + for uri in self.uris: + playlist.add(uri, 0) + self.assertEqual(uri, playlist.tracks[0].uri) + + # FIXME test other placements + +class BasePlaybackControllerTest(object): + backend_class = None + + def setUp(self): + self.backend = self.backend_class() + + def test_play(self): + playback = self.backend.playback + + self.assertEqual(playback.state, playback.STOPPED) + + playback.play() + + self.assertEqual(playback.state, playback.PLAYING) + + def test_next(self): + playback = self.backend.playback + + current_song = playback.playlist_position + + playback.next() + + self.assertEqual(playback.playlist_position, current_song+1) diff --git a/tests/mixers/__init__.py b/tests/mixers/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/mixers/denontest.py b/tests/mixers/denon_test.py similarity index 100% rename from tests/mixers/denontest.py rename to tests/mixers/denon_test.py diff --git a/tests/mixers/dummytest.py b/tests/mixers/dummy_test.py similarity index 100% rename from tests/mixers/dummytest.py rename to tests/mixers/dummy_test.py diff --git a/tests/modelstest.py b/tests/models_test.py similarity index 100% rename from tests/modelstest.py rename to tests/models_test.py diff --git a/tests/mpd/__init__.py b/tests/mpd/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/mpd/frontendtest.py b/tests/mpd/frontend_test.py similarity index 100% rename from tests/mpd/frontendtest.py rename to tests/mpd/frontend_test.py