[Pkg-mpd-commits] [python-mpd] 201/262: Imported Upstream version 0.5.1
Simon McVittie
smcv at debian.org
Sun May 22 18:16:47 UTC 2016
This is an automated email from the git hooks/post-receive script.
smcv pushed a commit to branch upstream
in repository python-mpd.
commit d5f60c32bb386fe93d6ad21635680c2777b4f90b
Author: kaliko <efrim at azylum.org>
Date: Tue Apr 9 21:51:58 2013 +0200
Imported Upstream version 0.5.1
---
CHANGES.rst | 4 ++
MANIFEST.in | 3 +-
Makefile | 9 +++
README.rst | 170 ++++++++++++++++++++++++++++++++++---------------------
doc/commands.rst | 158 +++++++++++++++++++++++++++++++++++++++++++++++++++
doc/commands.txt | 111 ------------------------------------
mpd.py | 10 +++-
setup.py | 17 +++---
test.py | 19 +++++++
9 files changed, 313 insertions(+), 188 deletions(-)
diff --git a/CHANGES.rst b/CHANGES.rst
index 92b7992..2cd2e37 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -1,6 +1,10 @@
python-mpd2 Changes List
========================
+Changes in v0.5.1
+-----------------
+* add support for ranges
+
Changes in 0.5.0
----------------
* improved support for sticker
diff --git a/MANIFEST.in b/MANIFEST.in
index 066ee11..6b05c80 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -1,3 +1,4 @@
exclude setup.cfg
include *.txt
-recursive-include doc *.txt
+include *.rst
+recursive-include doc *.rst
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..9abb9a7
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,9 @@
+VERSION=`python -c "import mpd; print('.'.join(map(str,mpd.VERSION)))"`
+
+test:
+ python setup.py test
+release: test
+ git tag $(VERSION)
+ python setup.py sdist upload
+clean:
+ python setup.py clean
diff --git a/README.rst b/README.rst
index 3162c83..0188204 100644
--- a/README.rst
+++ b/README.rst
@@ -6,17 +6,15 @@ python-mpd2
:alt: Build Status
*python-mpd2* is a Python library which provides a client interface for
-the `Music Player Daemon <http://musicpd.org>`_.
+the `Music Player Daemon <http://musicpd.org>`__.
Difference with python-mpd
--------------------------
-python-mpd2 is a fork of
-`python-mpd <http://jatreuman.indefero.net/p/python-mpd/>`_.
-python-mpd2 is a fork of `python-mpd`_. While 0.4.x was backwards compatible
-with python-mpd, starting with 0.5 provides enhanced features
-which are *NOT* backward compatibles with the original `python-mpd`_ package.
-(see PORTING.txt for more information)
+python-mpd2 is a fork of `python-mpd`_. While 0.4.x was backwards compatible
+with python-mpd, starting with 0.5 provides enhanced features which are *NOT*
+backward compatibles with the original `python-mpd`_ package. (see PORTING.txt
+for more information)
The following features were added:
@@ -26,19 +24,19 @@ The following features were added:
config, searchadd, searchaddpl)
- remove deprecated commands (volume)
- explicitly declared MPD commands (which is handy when using for
- example `IPython <http://ipython.org>`_)
+ example `IPython <http://ipython.org>`__)
- a test suite
-- API documentation to add new commands (see `Future
- Compatible <#future-compatible>`_)
+- API documentation to add new commands (see `Future Compatible`_
- support for Unicode strings in all commands (optionally in python2,
- default in python3 - see `Unicode Handling <#unicode-handling>`_)
+ default in python3 - see `Unicode Handling`_)
- configureable timeouts
-- support for `logging <#logging>`_
+- support for `logging`_
- improved support for sticker
+- improved support for ranges
If you like this module, you could try contact the original author
-jat at spatialrift.net or join the discussion on the `issue
-tracker <http://jatreuman.indefero.net/p/python-mpd/issues/7/>`_ so that
+jat at spatialrift.net or join the discussion on the
+`issue tracker <http://jatreuman.indefero.net/p/python-mpd/issues/7/>`__ so that
it gets merged upstream.
Getting the latest source code
@@ -56,16 +54,15 @@ To install *python-mpd2* from source, simply run the command::
$ python setup.py install
-You can use the *--help* switch to *setup.py* for a complete list of
-commands and their options. See the `Installing Python
-Modules <http://docs.python.org/inst/inst.html>`_ document for more
-details.
+You can use the *--help* switch to *setup.py* for a complete list of commands
+and their options. See the `Installing Python Modules
+<http://docs.python.org/inst/inst.html>`__ document for more details.
Getting the latest release
--------------------------
The latest stable release of *python-mpd2* can be found on
-`PyPI <http://pypi.python.org/pypi?:action=display&name=python-mpd2>`_
+`PyPI <http://pypi.python.org/pypi?:action=display&name=python-mpd2>`__
PyPI:
~~~~~
@@ -100,7 +97,7 @@ aptitude:
Arch Linux
~~~~~~~~~~
-Install `python-mpd2 <http://aur.archlinux.org/packages.php?ID=59276>`_
+Install `python-mpd2 <http://aur.archlinux.org/packages.php?ID=59276>`__
from AUR.
Gentoo Linux
@@ -108,8 +105,14 @@ Gentoo Linux
Replaces the original python-mpd beginning with version 0.4.2::
- echo dev-python/python-mpd >> /etc/portage/accept_keywords
- emerge -av python-mpd
+ $ emerge -av python-mpd
+
+FreeBSD
+~~~~~~~
+
+Install *py-mpd2*::
+
+ $ pkg_add -r py-mpd2
Packages for other distributions are welcome!
@@ -118,27 +121,27 @@ Using the client library
The client library can be used as follows::
- client = mpd.MPDClient() # create client object
- client.timeout = 10 # network timeout in seconds (floats allowed), default: None
- client.idletimeout = None # timeout for fetching the result of the idle command is handled seperately, default: None
- client.connect("localhost", 6600) # connect to localhost:6600
- print(client.mpd_version) # print the MPD version
- print(client.find("any", "house")) # print result of the command "find any house"
- client.close() # send the close command
- client.disconnect() # disconnect from the server
+ >>> client = mpd.MPDClient() # create client object
+ >>> client.timeout = 10 # network timeout in seconds (floats allowed), default: None
+ >>> client.idletimeout = None # timeout for fetching the result of the idle command is handled seperately, default: None
+ >>> client.connect("localhost", 6600) # connect to localhost:6600
+ >>> print(client.mpd_version) # print the MPD version
+ >>> print(client.find("any", "house")) # print result of the command "find any house"
+ >>> client.close() # send the close command
+ >>> client.disconnect() # disconnect from the server
-A list of supported commands, their arguments (as MPD currently
-understands them), and the functions used to parse their responses can
-be found in *doc/commands.txt*. See the `MPD protocol
-documentation <http://www.musicpd.org/doc/protocol/>`_ for more details.
+A list of supported commands, their arguments (as MPD currently understands
+them), and the functions used to parse their responses can be found in
+*doc/commands.txt*. See the `MPD protocol documentation
+<http://www.musicpd.org/doc/protocol/>`__ for more details.
Command lists are also supported using *command\_list\_ok\_begin()* and
*command\_list\_end()*::
- client.command_list_ok_begin() # start a command list
- client.update() # insert the update command into the list
- client.status() # insert the status command into the list
- results = client.command_list_end() # results will be a list with the results
+ >>> client.command_list_ok_begin() # start a command list
+ >>> client.update() # insert the update command into the list
+ >>> client.status() # insert the status command into the list
+ >>> results = client.command_list_end() # results will be a list with the results
Commands may also return iterators instead of lists if *iterate* is set
to *True*::
@@ -147,18 +150,43 @@ to *True*::
for song in client.playlistinfo():
print song["file"]
-Each command have a *send\_* and a *fetch\_* variant, which allows to
-send a MPD command and then fetch the result later. This is useful for
-the idle command::
+Each command have a *send\_* and a *fetch\_* variant, which allows to send a MPD
+command and then fetch the result later. This is useful for the idle command::
- client.send_idle()
+ >>> client.send_idle()
# do something else or use function like select(): http://docs.python.org/howto/sockets.html#non-blocking-sockets
# ex. select([client], [], []) or with gobject: http://jatreuman.indefero.net/p/python-mpd/page/ExampleIdle/
- events = client.fetch_idle()
+ >>> events = client.fetch_idle()
Some more complex usage examples can be found
`here <http://jatreuman.indefero.net/p/python-mpd/doc/>`_
+Range
+-----
+
+Some commands support integer ranges as argument. This is done in python-mpd2
+by using two element tuple::
+
+ # move the first three songs
+ # after the last in the playlist
+ >>> client.status()
+ ['file: song1.mp3',
+ 'file: song2.mp3',
+ 'file: song3.mp3',
+ 'file: song4.mp3']
+ >>> client.move((0,3), 1)
+ >>> client.status()
+ ['file: song4.mp3'
+ 'file: song1.mp3',
+ 'file: song2.mp3',
+ 'file: song3.mp3',]
+
+Second element can be omitted. MPD will assumes the biggest possible number then (don't forget the comma!)::
+NOTE: mpd versions between 0.16.8 and 0.17.3 contains a bug, so ommiting doesn't work.
+
+ >>> client.delete((1,)) # delete all songs, but the first.
+
+
Unicode Handling
----------------
@@ -169,24 +197,31 @@ To quote the mpd protocol documentation:
With Python 3:
~~~~~~~~~~~~~~
-In Python 3, Unicode string is the default string type. So just pass
-these strings as arguments for MPD commands and *python-mpd2* will also
-return such Unicode string.
+In Python 3, Unicode string is the default string type. So just pass these
+strings as arguments for MPD commands and *python-mpd2* will also return such
+Unicode string.
With Python 2.x
~~~~~~~~~~~~~~~
-For backward compatibility with *python-mpd*, when running with Python
-2.x, *python-mpd2* accepts both Unicode strings (ex. u"♥") and UTF-8
-encoded strings (ex. "♥").
+For backward compatibility with *python-mpd*, when running with Python 2.x,
+*python-mpd2* accepts both Unicode strings (ex. u"♥") and UTF-8 encoded strings
+(ex. "♥").
-In order for *MPDClient* to return Unicode strings with Python 2, create
-the instance with the ``use_unicode`` parameter set to ``True``.
+In order for *MPDClient* to return Unicode strings with Python 2, create the
+instance with the ``use_unicode`` parameter set to ``True``.
-Using Unicode strings should be prefered as it is done transparently by
-the library for you, and makes the transition to Python 3 easier.
+Using Unicode strings should be prefered as it is done transparently by the
+library for you, and makes the transition to Python 3 easier::
+
+ >>> import mpd
+ >>> client = MPDClient(use_unicode=True)
+ >>> client.urlhandlers()[0]
+ u'http'
+ >>> client.use_unicode = False # Can be switched back later
+ >>> client.urlhandlers()[0]
+ 'http'
-``python >>> import mpd >>> client = MPDClient(use_unicode=True) >>> client.urlhandlers()[0] u'http' >>> client.use_unicode = False # Can be switched back later >>> client.urlhandlers()[0] 'http'``
Using this option in Python 3 doesn't have any effect.
Logging
@@ -208,9 +243,9 @@ http://docs.python.org/2/howto/logging.html
Future Compatible
-----------------
-New commands or special handling of commands can be easily implemented.
-Use ``add_command()`` or ``remove_command()`` to modify the commands of
-the *MPDClient* class and all its instances.::
+New commands or special handling of commands can be easily implemented. Use
+``add_command()`` or ``remove_command()`` to modify the commands of the
+*MPDClient* class and all its instances.::
def fetch_cover(client):
""""Take a MPDClient instance as its arguments and return mimetype and image"""
@@ -227,12 +262,12 @@ the *MPDClient* class and all its instances.::
Thread-Safety
-------------
-Currently ``MPDClient`` is **NOT** thread-safe. As it use a socket
-internaly, only one thread can send or receive at the time.
+Currently ``MPDClient`` is **NOT** thread-safe. As it use a socket internaly,
+only one thread can send or receive at the time.
-But ``MPDClient`` can be easily extended to be thread-safe using
-`locks <http://docs.python.org/library/threading.html#lock-objects>`_.
-Take a look at ``examples/locking.py`` for further informations.
+But ``MPDClient`` can be easily extended to be thread-safe using `locks
+<http://docs.python.org/library/threading.html#lock-objects>`__. Take a look at
+``examples/locking.py`` for further informations.
Testing
-------
@@ -241,8 +276,9 @@ Just run::
$ python setup.py test
-This will install `Tox <http://tox.testrun.org/>`_.
-Tox will take care of testing against all the supported Python versions (at least available) on our computer, with the required dependencies
+This will install `Tox <http://tox.testrun.org/>`__. Tox will take care of
+testing against all the supported Python versions (at least available) on our
+computer, with the required dependencies
Contacting the author
---------------------
@@ -251,9 +287,11 @@ Just contact me (Mic92) on Github or via email (joerg at higgsboson.tk).
Usually I hang around on Jabber: sonata at conference.codingteam.net
-You can contact the original author by emailing J. Alexander Treuman
-jat at spatialrift.net.
+You can contact the original author by emailing
+J. Alexander Treuman jat at spatialrift.net.
He can also be found idling in #mpd on irc.freenode.net as jat.
.. |Build Status| image:: https://travis-ci.org/Mic92/python-mpd2.png
+
+.. _python-mpd: http://jatreuman.indefero.net/p/python-mpd/
diff --git a/doc/commands.rst b/doc/commands.rst
new file mode 100644
index 0000000..b6bf5c7
--- /dev/null
+++ b/doc/commands.rst
@@ -0,0 +1,158 @@
+========
+Commands
+========
+
+Status Commands
+---------------
+
+=========== ======= =============
+clearerror fetch_nothing
+currentsong fetch_object
+idle [<str>] fetch_list
+noidle None
+status fetch_object
+stats fetch_object
+=========== ======= =============
+
+Playback Option Commands
+------------------------
+================== ====== =============
+consume <bool> fetch_nothing
+crossfade <int> fetch_nothing
+mixrampdb <str> fetch_nothing
+mixrampdelay <int> fetch_nothing
+random <bool> fetch_nothing
+repeat <bool> fetch_nothing
+setvol <int> fetch_nothing
+single <bool> fetch_nothing
+replay_gain_mode <str> fetch_nothing
+replay_gain_status fetch_item
+================== ====== =============
+
+Playback Control Commands
+-------------------------
+
+======== =========== =============
+next fetch_nothing
+pause [<bool>] fetch_nothing
+play [<int>] fetch_nothing
+playid [<int>] fetch_nothing
+previous fetch_nothing
+seek <int> <int> fetch_nothing
+seekid <int> <int> fetch_nothing
+seekcur <int> fetch_nothing
+stop fetch_nothing
+======== =========== =============
+
+Playlist Commands
+-----------------
+
+============== ============= =============
+add <str> fetch_nothing
+addid <str> [<int>] fetch_item
+clear fetch_nothing
+delete <int> fetch_nothing
+deleteid <int> fetch_nothing
+move <int> <int> fetch_nothing
+moveid <int> <int> fetch_nothing
+playlist fetch_playlist
+playlistfind <locate> fetch_songs
+playlistid [<int>] fetch_songs
+playlistinfo [<int>] fetch_songs
+playlistsearch <locate> fetch_songs
+plchanges <int> fetch_songs
+plchangesposid <int> fetch_changes
+prio <int> <str> fetch_nothing
+prioid <int> <id> fetch_nothing
+shuffle [<str>] fetch_nothing
+swap <int> <int> fetch_nothing
+swapid <int> <int> fetch_nothing
+============== ============= =============
+
+Stored Playlist Commands
+------------------------
+
+================ ================= ===============
+listplaylist <str> fetch_list
+listplaylistinfo <str> fetch_songs
+listplaylists fetch_playlists
+load <str> fetch_nothing
+playlistadd <str> <str> fetch_nothing
+playlistclear <str> fetch_nothing
+playlistdelete <str> <int> fetch_nothing
+playlistmove <str> <int> <int> fetch_nothing
+rename <str> <str> fetch_nothing
+rm <str> fetch_nothing
+save <str> fetch_nothing
+================ ================= ===============
+
+Database Commands
+-----------------
+
+=========== ================ ==============
+count <locate> fetch_object
+find <locate> fetch_songs
+findadd <locate> fetch_nothing
+list <str> [<locate>] fetch_list
+listall [<str>] fetch_database
+listallinfo [<str>] fetch_database
+lsinfo [<str>] fetch_database
+search <locate> fetch_songs
+searchadd <locate> fetch_songs
+searchaddpl <str> <locate> fetch_songs
+update [<str>] fetch_item
+rescan [<str>] fetch_item
+=========== ================ ==============
+
+Sticker Commands
+----------------
+
+============== ======================= =============
+sticker get <str> <str> <str> fetch_item
+sticker set <str> <str> <str> <str> fetch_nothing
+sticker delete <str> <str> [<str>] fetch_nothing
+sticker list <str> <str> fetch_list
+sticker find <str> <str> <str> fetch_songs
+============== ======================= =============
+
+Connection Commands
+-------------------
+
+======== ===== =============
+close None
+kill None
+password <str> fetch_nothing
+ping fetch_nothing
+======== ===== =============
+
+Audio Output Commands
+---------------------
+
+============= ===== =============
+disableoutput <int> fetch_nothing
+enableoutput <int> fetch_nothing
+outputs fetch_outputs
+============= ===== =============
+
+Reflection Commands
+-------------------
+
+=========== =============
+config fetch_item
+commands fetch_list
+notcommands fetch_list
+tagtypes fetch_list
+urlhandlers fetch_list
+decoders fetch_plugins
+=========== =============
+
+Client To Client
+----------------
+
+============ =========== ==============
+subscribe <str> fetch_nothing
+unsubscribe <str> fetch_nothing
+channels fetch_list
+readmessages fetch_messages
+sendmessage <str> <str> fetch_nothing
+============ =========== ==============
diff --git a/doc/commands.txt b/doc/commands.txt
deleted file mode 100644
index 97dcea7..0000000
--- a/doc/commands.txt
+++ /dev/null
@@ -1,111 +0,0 @@
-== Status Commands
-clearerror -> fetch_nothing
-currentsong -> fetch_object
-idle [<str>] -> fetch_list
-noidle -> None
-status -> fetch_object
-stats -> fetch_object
-
-== Playback Option Commands
-consume <bool> -> fetch_nothing
-crossfade <int> -> fetch_nothing
-mixrampdb <str> -> fetch_nothing
-mixrampdelay <int> -> fetch_nothing
-random <bool> -> fetch_nothing
-repeat <bool> -> fetch_nothing
-setvol <int> -> fetch_nothing
-single <bool> -> fetch_nothing
-replay_gain_mode <str> -> fetch_nothing
-replay_gain_status -> fetch_item
-
-== Playback Control Commands
-next -> fetch_nothing
-pause [<bool>] -> fetch_nothing
-play [<int>] -> fetch_nothing
-playid [<int>] -> fetch_nothing
-previous -> fetch_nothing
-seek <int> <int> -> fetch_nothing
-seekid <int> <int> -> fetch_nothing
-seekcur <int> -> fetch_nothing
-stop -> fetch_nothing
-
-== Playlist Commands
-add <str> -> fetch_nothing
-addid <str> [<int>] -> fetch_item
-clear -> fetch_nothing
-delete <int> -> fetch_nothing
-deleteid <int> -> fetch_nothing
-move <int> <int> -> fetch_nothing
-moveid <int> <int> -> fetch_nothing
-playlist -> fetch_playlist
-playlistfind <locate> -> fetch_songs
-playlistid [<int>] -> fetch_songs
-playlistinfo [<int>] -> fetch_songs
-playlistsearch <locate> -> fetch_songs
-plchanges <int> -> fetch_songs
-plchangesposid <int> -> fetch_changes
-prio <int> <str> -> fetch_nothing
-prioid <int> <id> -> fetch_nothing
-shuffle [<str>] -> fetch_nothing
-swap <int> <int> -> fetch_nothing
-swapid <int> <int> -> fetch_nothing
-
-== Stored Playlist Commands
-listplaylist <str> -> fetch_list
-listplaylistinfo <str> -> fetch_songs
-listplaylists -> fetch_playlists
-load <str> -> fetch_nothing
-playlistadd <str> <str> -> fetch_nothing
-playlistclear <str> -> fetch_nothing
-playlistdelete <str> <int> -> fetch_nothing
-playlistmove <str> <int> <int> -> fetch_nothing
-rename <str> <str> -> fetch_nothing
-rm <str> -> fetch_nothing
-save <str> -> fetch_nothing
-
-== Database Commands
-count <locate> -> fetch_object
-find <locate> -> fetch_songs
-findadd <locate> -> fetch_nothing
-list <str> [<locate>] -> fetch_list
-listall [<str>] -> fetch_database
-listallinfo [<str>] -> fetch_database
-lsinfo [<str>] -> fetch_database
-search <locate> -> fetch_songs
-searchadd <locate> -> fetch_songs
-searchaddpl <str> <locate> -> fetch_songs
-update [<str>] -> fetch_item
-rescan [<str>] -> fetch_item
-
-== Sticker Commands
-sticker get <str> <str> <str> -> fetch_item
-sticker set <str> <str> <str> <str> -> fetch_nothing
-sticker delete <str> <str> [<str>] -> fetch_nothing
-sticker list <str> <str> -> fetch_list
-sticker find <str> <str> <str> -> fetch_songs
-
-== Connection Commands
-close -> None
-kill -> None
-password <str> -> fetch_nothing
-ping -> fetch_nothing
-
-== Audio Output Commands
-disableoutput <int> -> fetch_nothing
-enableoutput <int> -> fetch_nothing
-outputs -> fetch_outputs
-
-== Reflection Commands
-config -> fetch_item
-commands -> fetch_list
-notcommands -> fetch_list
-tagtypes -> fetch_list
-urlhandlers -> fetch_list
-decoders -> fetch_plugins
-
-== Client To Client
-subscribe <str> -> fetch_nothing
-unsubscribe <str> -> fetch_nothing
-channels -> fetch_list
-readmessages -> fetch_messages
-sendmessage <str> <str> -> fetch_nothing
diff --git a/mpd.py b/mpd.py
index c93b4bd..a7fd522 100644
--- a/mpd.py
+++ b/mpd.py
@@ -21,7 +21,7 @@ import socket
import warnings
from collections import Callable
-VERSION = (0, 5, 0)
+VERSION = (0, 5, 1)
HELLO_PREFIX = "OK MPD "
ERROR_PREFIX = "ACK "
SUCCESS = "OK"
@@ -235,7 +235,13 @@ class MPDClient(object):
def _write_command(self, command, args=[]):
parts = [command]
for arg in args:
- parts.append('"%s"' % escape(encode_str(arg)))
+ if type(arg) is tuple:
+ if len(arg) == 1:
+ parts.append('"%d:"' % int(arg[0]))
+ else:
+ parts.append('"%d:%d"' % (int(arg[0]), int(arg[1])))
+ else:
+ parts.append('"%s"' % escape(encode_str(arg)))
# Minimize logging cost if the logging is not activated.
if logger.isEnabledFor(logging.DEBUG):
if command == "password":
diff --git a/setup.py b/setup.py
index e6e08a3..06e8d07 100644
--- a/setup.py
+++ b/setup.py
@@ -3,13 +3,9 @@
from distutils.core import setup
from setuptools import Extension
from setuptools.command.test import test as TestCommand
-import sys
+import sys,os
import mpd
-DESCRIPTION = """\
-An MPD (Music Player Daemon) client library written in pure Python.\
-"""
-
CLASSIFIERS = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
@@ -48,15 +44,20 @@ class Tox(TestCommand):
errno = tox.cmdline(self.test_args)
sys.exit(errno)
+def read(fname):
+ return open(os.path.join(os.path.dirname(__file__), fname)).read()
+
+VERSION = ".".join(map(str, mpd.VERSION))
+
setup(
name="python-mpd2",
- version=".".join(map(str, mpd.VERSION)),
+ version=VERSION,
description="A Python MPD client library",
- long_description=DESCRIPTION,
+ long_description=read('README.rst'),
author="J. Thalheim",
author_email="jthalheim at gmail.com",
url="https://github.com/Mic92/python-mpd2",
- download_url="https://github.com/Mic92/python-mpd2",
+ download_url="https://github.com/Mic92/python-mpd2/archive/v%s.zip" % VERSION,
py_modules=["mpd"],
classifiers=CLASSIFIERS,
#license=LICENSE,
diff --git a/test.py b/test.py
index f216b29..14d5f0b 100755
--- a/test.py
+++ b/test.py
@@ -301,6 +301,25 @@ class TestMPDClient(unittest.TestCase):
# otherwise we get all the readline() & co...
self.client._sock.makefile.call_args_list[0:2])
+ def test_ranges_as_argument(self):
+ self.MPDWillReturn('OK\n')
+ self.client.move((1,2), 2)
+ self.assertMPDReceived('move "1:2" "2"\n')
+
+ self.MPDWillReturn('OK\n')
+ self.client.move((1,), 2)
+ self.assertMPDReceived('move "1:" "2"\n')
+
+ # old code still works!
+ self.MPDWillReturn('OK\n')
+ self.client.move("1:2", 2)
+ self.assertMPDReceived('move "1:2" "2"\n')
+
+ with self.assertRaises(ValueError):
+ self.MPDWillReturn('OK\n')
+ self.client.move((1,"garbage"), 2)
+ self.assertMPDReceived('move "1:" "2"\n')
+
def test_read_stickers(self):
self.MPDWillReturn("sticker: foo=bar\n", "OK\n")
res = self.client._read_stickers()
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mpd/python-mpd.git
More information about the Pkg-mpd-commits
mailing list