diff --git a/plugins/Nickometer/plugin.py b/plugins/Nickometer/plugin.py index 686ee266b..59751cf95 100644 --- a/plugins/Nickometer/plugin.py +++ b/plugins/Nickometer/plugin.py @@ -45,8 +45,6 @@ # # ### -from __future__ import division - import supybot import re @@ -224,7 +222,7 @@ class Nickometer(callbacks.Plugin): # Use an appropriate function to map [0, +inf) to [0, 100) percentage = 100 * (1 + math.tanh((score - 400.0) / 400.0)) * \ - (1 - 1 / (1 + score / 5.0)) // 2 + (1 - 1 / (1 + score / 5.0)) / 2 # if it's above 99.9%, show as many digits as is interesting score_string=re.sub('(99\\.9*\\d|\\.\\d).*','\\1',repr(percentage)) diff --git a/plugins/Nickometer/test.py b/plugins/Nickometer/test.py index 5029ca5c6..2b2f29542 100644 --- a/plugins/Nickometer/test.py +++ b/plugins/Nickometer/test.py @@ -33,6 +33,12 @@ class NickometerTestCase(PluginTestCase): plugins = ('Nickometer',) def testNickometer(self): self.assertNotError('nickometer') - self.assertNotError('nickometer jemfinch') + self.assertResponse( + 'nickometer jemfinch', + 'The "lame nick-o-meter" reading for "jemfinch" is 0.0%.') + nick = 'xXReallyObnoxious1337NickXx' + self.assertResponse( + 'nickometer %s' % nick, + 'The "lame nick-o-meter" reading for "%s" is 99.96%%.' % nick) # vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: