Skip to content

Commit

Permalink
Added python version check for some math evaluation test cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
gunthercox committed Jan 16, 2016
1 parent 1b2d740 commit 890d242
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions tests/logic_adapter_tests/test_evaluate_mathematically.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@
class MathematicalEvaluationTests(TestCase):

def setUp(self):
import sys

self.adapter = EvaluateMathematically()

# Some tests may return decimals under python 3
self.python_version = sys.version_info[0]

def test_addition_operator(self):
statement = Statement("What is 100 + 54?")
confidence, response = self.adapter.process(statement)
Expand All @@ -26,7 +31,11 @@ def test_multiplication_operator(self):
def test_division_operator(self):
statement = Statement("What is 100 / 20")
confidence, response = self.adapter.process(statement)
self.assertEqual(response.text, "( 100 / 20 ) = 5")

if self.python_version <= 2:
self.assertEqual(response.text, "( 100 / 20 ) = 5")
else:
self.assertEqual(response.text, "( 100 / 20 ) = 5.0")

def test_parenthesized_multiplication_and_addition(self):
statement = Statement("What is 100 + ( 1000 * 2 )?")
Expand All @@ -46,12 +55,20 @@ def test_word_numbers_addition(self):
def test_word_division_operator(self):
statement = Statement("What is 100 divided by 100?")
confidence, response = self.adapter.process(statement)
self.assertEqual(response.text, "( 100 / 100 ) = 1")

if self.python_version <= 2:
self.assertEqual(response.text, "( 100 / 100 ) = 1")
else:
self.assertEqual(response.text, "( 100 / 100 ) = 1.0")

def test_large_word_division_operator(self):
statement = Statement("What is one thousand two hundred four divided by one hundred?")
confidence, response = self.adapter.process(statement)
self.assertEqual(response.text, "( 1000 + 200 + 4 ) / ( 100 ) = 12")

if self.python_version <= 2:
self.assertEqual(response.text, "( 1000 + 200 + 4 ) / ( 100 ) = 12")
else:
self.assertEqual(response.text, "( 1000 + 200 + 4 ) / ( 100 ) = 12.04")

def test_negative_multiplication(self):
statement = Statement("What is -105 * 5")
Expand Down

0 comments on commit 890d242

Please sign in to comment.