Made sure IrcUser.removeCapability raises KeyError on capabilities the user doesn't have.

This commit is contained in:
Jeremy Fincher 2003-09-23 17:04:53 +00:00
parent b1654bd4bc
commit b50a01db7d
2 changed files with 5 additions and 2 deletions

View File

@ -194,8 +194,7 @@ class IrcUser(object):
self.capabilities.add(capability) self.capabilities.add(capability)
def removeCapability(self, capability): def removeCapability(self, capability):
if capability in self.capabilities: self.capabilities.remove(capability)
self.capabilities.remove(capability)
def checkCapability(self, capability): def checkCapability(self, capability):
if self.ignore: if self.ignore:

View File

@ -223,6 +223,10 @@ class IrcUserTestCase(unittest.TestCase):
self.failIf(u.checkCapability('foo')) self.failIf(u.checkCapability('foo'))
self.failUnless(u.checkCapability('!foo')) self.failUnless(u.checkCapability('!foo'))
def testRemoveCapability(self):
u = ircdb.IrcUser(capabilities=('foo',))
self.assertRaises(KeyError, u.removeCapability, 'bar')
class IrcChannelTestCase(unittest.TestCase): class IrcChannelTestCase(unittest.TestCase):
def testInit(self): def testInit(self):
c = ircdb.IrcChannel() c = ircdb.IrcChannel()