diff --git a/tests/logic_adapter_tests/test_evaluate_mathematically.py b/tests/logic_adapter_tests/test_evaluate_mathematically.py index 6709ef762..5dc01a77a 100644 --- a/tests/logic_adapter_tests/test_evaluate_mathematically.py +++ b/tests/logic_adapter_tests/test_evaluate_mathematically.py @@ -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) @@ -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 )?") @@ -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")