Jason R. Coombs avatar Jason R. Coombs committed d0659c7

Fixed failing tests

Comments (0)

Files changed (1)

test/test_commands.py

 # -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
 import re
 
 from pmxbot_wolframalpha import wa
 		"""
 		Basic wolframalpha command - 1+1 must include 2 in results
 		"""
-		res = ' '.join(wa(c, e, "#test", "testrunner", "1+1"))
-		print res
+		res = wa(c, e, "#test", "testrunner", "1+1")
 		assert "2" in res
 
 	def test_wolframalpha_complicated(self):
 		More complicated wolframalpha command - 40 gallons in liters must
 		include 151.4 in results
 		"""
-		res = ' '.join(wa(c, e, "#test", "testrunner", "40 gallons in liters"))
-		print res
+		res = wa(c, e, "#test", "testrunner", "40 gallons in liters")
 		assert "151.4" in res
 
 	def test_wolframalpha_supercomplicated(self):
 		"""
-		Supercomplicated wolframalpha command - 502 hogsheads per mile in litres per km
+		Supercomplicated wolframalpha command - 502 hogsheads per mile in
+		litres per km
 		include 74 388.9641 in results
 		"""
-		res = ' '.join(wa(c, e, "#test", "testrunner", "502 hogsheads per mile in litres per km"))
-		print res
-		import pickle
-		pickle.dump(res, open('bleh.cp', 'wb'))
+		res = wa(c, e, "#test", "testrunner",
+			"502 hogsheads per mile in litres per km")
 		assert "74" in res and ('388.' in res or '389' in res)
 
 	def test_wolframalpha_currency_usd_gbp(self):
 		"""
 		Test that wolframalpha for a currency conversion: 1 USD in GBP
 		"""
-		res = ' '.join(wa(c, e, "#test", "testrunner", "1 USD in GBP"))
-		print res
-		assert re.search(r"""1.+?dollar.+?\d\.\d+ .+?British pound""", res)
+		res = wa(c, e, "#test", "testrunner", "1 USD in GBP")
+		pattern = '£\d+\.\d+\s+' + re.escape('(British pounds)')
+		assert re.match(pattern, res)
 
 	def test_wolframalpha_currency_czk_euro(self):
 		"""
 		Test that wolframalpha for a currency conversion: 12 CZK in euros
 		"""
-		res = ' '.join(wa(c, e, "#test", "testrunner", "12 CZK in euros"))
-		print res
-		assert re.search(r"""K.12.+?[Ee]uros? *\d\.\d+""", res)
+		res = wa(c, e, "#test", "testrunner", "12 CZK in euros")
+		pattern = 'euro\d+\.\d+\s+' + re.escape('(euros)')
+		assert re.match(pattern, res)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.