From 3e28059c9eb166efc28643874fc30e03df7f4841 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Mon, 22 Sep 2003 17:32:12 +0000 Subject: [PATCH] Fixed bug in genre pluralization. --- plugins/IMDB.py | 6 ++++-- test/test_IMDB.py | 8 ++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/plugins/IMDB.py b/plugins/IMDB.py index 17807ed68..23aa2cb50 100644 --- a/plugins/IMDB.py +++ b/plugins/IMDB.py @@ -68,10 +68,12 @@ class IMDB(callbacks.Privmsg): def _formatMovie(self, movie): title = utils.unCommaThe(movie.title()) genres = utils.commaAndify(map(str.lower, movie.genres())) - s = '"%s" (%s) belongs to the %s genres. ' \ + s = '"%s" (%s) belongs to the %s %s. ' \ 'It\'s been rated %s out of 10. ' \ 'More information is available at <%s>' % \ - (title, movie.year(), genres, movie.rating(), movie.url) + (title, movie.year(), genres, + utils.pluralize(len(movie.genres()), 'genre'), + movie.rating(), movie.url) return s def imdb(self, irc, msg, args): diff --git a/test/test_IMDB.py b/test/test_IMDB.py index 4495ed8d6..9f8f55e8f 100644 --- a/test/test_IMDB.py +++ b/test/test_IMDB.py @@ -35,8 +35,12 @@ class IMDBTestCase(PluginTestCase, PluginDocumentation): plugins = ('IMDB',) def testImdb(self): self.assertNotError('imdb die hard') - m = self.getMsg('imdb kevin spacey') - self.failUnless('is apparently a person' in m.args[1]) + self.assertRegexp('imdb kevin spacey', 'is apparently a person') + + def testGenrePluralization(self): + self.assertNotRegexp('imdb 24', 'genres') + self.assertRegexp('imdb die hard', 'genres') + # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: