calc: fix .c scientific output

master
mutantmonkey 2012-06-05 18:24:43 -07:00
parent c702d7bc59
commit 2dbc8797e5
2 changed files with 9 additions and 1 deletions

View File

@ -41,7 +41,9 @@ def c(phenny, input):
if answer:
#answer = ''.join(chr(ord(c)) for c in answer)
#answer = answer.decode('utf-8')
answer = answer.replace('\xc2\xa0', ',')
answer = answer.replace('\\x26#215;', '*')
answer = answer.replace('\\x3c', '<')
answer = answer.replace('\\x3e', '>')
answer = answer.replace('<sup>', '^(')
answer = answer.replace('</sup>', ')')
answer = web.decode(answer)

View File

@ -18,6 +18,12 @@ class TestCalc(unittest.TestCase):
self.phenny.say.assert_called_once_with('25')
def test_c_scientific(self):
input = Mock(group=lambda x: '2^64')
c(self.phenny, input)
self.phenny.say.assert_called_once_with('1.84467441 * 10^(19)')
def test_py(self):
input = Mock(group=lambda x: "'test'*3")
py(self.phenny, input)