From 766dad2f70f886fb2f78b812984aeb82aa5dba36 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Wed, 1 Jun 2005 06:20:29 +0000 Subject: [PATCH] Fixed an error in hostmask.list when there are no hostmasks. --- plugins/User/plugin.py | 7 +++++-- plugins/User/test.py | 9 +++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/plugins/User/plugin.py b/plugins/User/plugin.py index a2167d541..2500b94d6 100644 --- a/plugins/User/plugin.py +++ b/plugins/User/plugin.py @@ -246,8 +246,11 @@ class User(callbacks.Plugin): """ def getHostmasks(user): hostmasks = map(repr, user.hostmasks) - hostmasks.sort() - return format('%L', hostmasks) + if hostmasks: + hostmasks.sort() + return format('%L', hostmasks) + else: + irc.reply(format('%s has no registered hostmasks.', user)) try: user = ircdb.users.getUser(msg.prefix) if name: diff --git a/plugins/User/test.py b/plugins/User/test.py index a93046618..a46dd44e9 100644 --- a/plugins/User/test.py +++ b/plugins/User/test.py @@ -47,6 +47,15 @@ class UserTestCase(PluginTestCase): self.assertNotError('hostmask add foo') self.assertNotRegexp('hostmask add foo', 'IrcSet') + def testHostmaskListHandlesEmptyListGracefully(self): + self.assertError('hostmask list') + self.prefix = self.prefix1 + self.assertNotError('register foo bar') + self.assertNotError('hostmask remove foo %s' % self.prefix1) + self.assertNotError('identify foo bar') + self.assertRegexp('hostmask list', 'no registered hostmasks') + + def testHostmask(self): self.assertResponse('hostmask', self.prefix) self.assertError('@hostmask asdf')