[Pkg-mpd-commits] [python-mpd] 95/262: raise an error, if removing a non existing command

Simon McVittie smcv at debian.org
Sun May 22 18:16:30 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 62647392c247038b98f8d40aefb82410a78d7507
Author: Jörg Thalheim <jthalheim at gmail.com>
Date:   Thu Feb 16 15:34:08 2012 +0100

    raise an error, if removing a non existing command
---
 mpd.py  | 3 ++-
 test.py | 3 +++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/mpd.py b/mpd.py
index f7c3d50..41ec15e 100644
--- a/mpd.py
+++ b/mpd.py
@@ -458,7 +458,8 @@ class MPDClient():
 
     @classmethod
     def remove_command(cls, name):
-        if not hasattr(cls, name): return
+        if not hasattr(cls, name):
+            raise ValueError("Can't remove not existent '%s' command" % name)
         name = name.replace(" ", "_")
         delattr(cls, str(name))
         delattr(cls, str("send_" + name))
diff --git a/test.py b/test.py
index 8bb91ae..40c5b9e 100755
--- a/test.py
+++ b/test.py
@@ -96,6 +96,9 @@ class TestMPDClient(unittest.TestCase):
         self.assertFalse(hasattr(self.client, "awesome_command"))
         self.assertFalse(hasattr(self.client, "send_awesome_command"))
         self.assertFalse(hasattr(self.client, "fetch_awesome_command"))
+        # remove non existing command
+        self.assertRaises(ValueError, self.client.remove_command,
+                          "awesome_command")
     def test_client_to_client(self):
         # client to client is at this time in beta!
         if not "channels" in self.client.commands():

-- 
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