Permalink
Browse files

raise an error, if removing a non existing command

  • Loading branch information...
1 parent e20b650 commit 62647392c247038b98f8d40aefb82410a78d7507 @Mic92 committed Feb 16, 2012
Showing with 5 additions and 1 deletion.
  1. +2 −1 mpd.py
  2. +3 −0 test.py
View
3 mpd.py
@@ -458,7 +458,8 @@ def add_command(cls, name, callback):
@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))
View
@@ -96,6 +96,9 @@ def test_add_and_remove_command(self):
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():

0 comments on commit 6264739

Please sign in to comment.