Fixed bug in info; returned n+1 factoids when there were only n.

This commit is contained in:
Jeremy Fincher 2003-10-23 04:17:18 +00:00
parent e255ef2e68
commit 65b87f822c
2 changed files with 6 additions and 2 deletions

View File

@ -339,12 +339,12 @@ class Factoids(plugins.ChannelDBHandler, callbacks.Privmsg):
ORDER BY id""", id) ORDER BY id""", id)
factoids = cursor.fetchall() factoids = cursor.fetchall()
L = [] L = []
counter = 1 counter = 0
for (added_by, added_at) in factoids: for (added_by, added_at) in factoids:
counter += 1
added_at = time.strftime(conf.humanTimestampFormat, added_at = time.strftime(conf.humanTimestampFormat,
time.localtime(int(added_at))) time.localtime(int(added_at)))
L.append('#%s was added by %s at %s' % (counter,added_by,added_at)) L.append('#%s was added by %s at %s' % (counter,added_by,added_at))
counter += 1
factoids = '; '.join(L) factoids = '; '.join(L)
s = 'Key %r is %s and has %s factoids associated with it: %s' % \ s = 'Key %r is %s and has %s factoids associated with it: %s' % \
(key, locked and 'locked' or 'not locked', counter, factoids) (key, locked and 'locked' or 'not locked', counter, factoids)

View File

@ -105,6 +105,10 @@ if sqlite is not None:
self.assertNotRegexp('info foo', '#0') self.assertNotRegexp('info foo', '#0')
self.assertNotRegexp('whatis foo', '#0') self.assertNotRegexp('whatis foo', '#0')
def testInfoReturnsRightNumber(self):
self.assertNotError('learn foo as bar')
self.assertNotRegexp('info foo', '2 factoids')
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: