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