Exemple #1
0
 def test_addition(self):
     self.assertEqual(answer("What is 1 plus 1?"), 2)
Exemple #2
0
 def test_missing_operation(self):
     with self.assertRaisesWithMessage(ValueError):
         answer("What is 2 2 minus 3?")
 def test_multiple_division(self):
     self.assertEqual(answer("What is -12 divided by 2 divided by -3?"), 2)
Exemple #4
0
 def test_unknown_operation(self):
     with self.assertRaisesWithMessage(ValueError):
         answer("What is 52 cubed?")
Exemple #5
0
 def test_reject_two_operations_in_a_row(self):
     with self.assertRaisesWithMessage(ValueError):
         answer('What is 1 plus plus 2?')
Exemple #6
0
 def test_division(self):
     self.assertEqual(answer("What is 33 divided by -3?"), -11)
Exemple #7
0
 def test_subtraction_then_addition(self):
     self.assertEqual(answer("What is 17 minus 6 plus 3?"), 14)
Exemple #8
0
 def test_reject_problem_missing_an_operand(self):
     with self.assertRaisesWithMessage(ValueError):
         answer('What is 1 plus?')
Exemple #9
0
 def test_reject_problem_with_no_operands_or_operators(self):
     with self.assertRaisesWithMessage(ValueError):
         answer('What is?')
Exemple #10
0
 def test_reject_postfix_notation(self):
     with self.assertRaisesWithMessage(ValueError):
         answer("What is 1 2 plus?")
Exemple #11
0
 def test_non_math_question(self):
     with self.assertRaisesWithMessage(ValueError):
         answer("Who is the President of the United States?")
Exemple #12
0
 def test_reject_prefix_notation(self):
     with self.assertRaises(ValueError) as err:
         answer("What is plus 1 2?")
     self.assertEqual(type(err.exception), ValueError)
     self.assertEqual(err.exception.args[0], "syntax error")
Exemple #13
0
 def test_reject_two_numbers_in_a_row(self):
     with self.assertRaises(ValueError) as err:
         answer("What is 1 plus 2 1?")
     self.assertEqual(type(err.exception), ValueError)
     self.assertEqual(err.exception.args[0], "syntax error")
Exemple #14
0
 def test_reject_problem_with_no_operands_or_operators(self):
     with self.assertRaises(ValueError) as err:
         answer("What is?")
     self.assertEqual(type(err.exception), ValueError)
     self.assertEqual(err.exception.args[0], "syntax error")
Exemple #15
0
 def test_addition_with_negative_numbers(self):
     self.assertEqual(answer("What is -1 plus -10?"), -11)
Exemple #16
0
 def test_reject_two_operations_in_a_row(self):
     with self.assertRaisesWithMessage(ValueError):
         answer('What is 1 plus plus 2?')
Exemple #17
0
 def test_subtraction(self):
     self.assertEqual(answer("What is 4 minus -12?"), 16)
Exemple #18
0
 def test_reject_two_numbers_in_a_row(self):
     with self.assertRaisesWithMessage(ValueError):
         answer('What is 1 plus 2 1?')
Exemple #19
0
 def test_addition_and_subtraction(self):
     self.assertEqual(answer("What is 1 plus 5 minus -2?"), 8)
Exemple #20
0
 def test_just_a_number(self):
     self.assertEqual(answer('What is 5?'), 5)
Exemple #21
0
 def test_addition_and_multiplication(self):
     self.assertEqual(answer("What is -3 plus 7 multiplied by -2?"), -8)
Exemple #22
0
 def test_reject_prefix_notation(self):
     with self.assertRaisesWithMessage(ValueError):
         answer('What is plus 1 2?')
Exemple #23
0
 def test_reject_problem_missing_an_operand(self):
     with self.assertRaisesWithMessage(ValueError):
         answer('What is 1 plus?')
Exemple #24
0
 def test_missing_operation(self):
     with self.assertRaisesWithMessage(ValueError):
         answer("What is 2 2 minus 3?")
Exemple #25
0
 def test_reject_prefix_notation(self):
     with self.assertRaisesWithMessage(ValueError):
         answer('What is plus 1 2?')
Exemple #26
0
 def test_missing_number(self):
     with self.assertRaisesWithMessage(ValueError):
         answer("What is 7 plus multiplied by -2?")
Exemple #27
0
 def test_reject_problem_missing_an_operand(self):
     with self.assertRaises(ValueError) as err:
         answer("What is 1 plus?")
     self.assertEqual(type(err.exception), ValueError)
     self.assertEqual(err.exception.args[0], "syntax error")
Exemple #28
0
 def test_addition(self):
     self.assertEqual(answer("What is 1 plus 1?"), 2)
Exemple #29
0
 def test_unknown_operation(self):
     with self.assertRaisesWithMessage(ValueError):
         answer("What is 52 cubed?")
Exemple #30
0
 def test_more_addition(self):
     self.assertEqual(answer("What is 53 plus 2?"), 55)
Exemple #31
0
 def test_more_addition(self):
     self.assertEqual(answer("What is 53 plus 2?"), 55)
Exemple #32
0
 def test_addition_with_negative_numbers(self):
     self.assertEqual(answer("What is -1 plus -10?"), -11)
Exemple #33
0
 def test_large_addition(self):
     self.assertEqual(answer("What is 123 plus 45678?"), 45801)
Exemple #34
0
 def test_large_addition(self):
     self.assertEqual(answer("What is 123 plus 45678?"), 45801)
Exemple #35
0
 def test_multiplication(self):
     self.assertEqual(answer("What is -3 multiplied by 25?"), -75)
Exemple #36
0
 def test_subtraction(self):
     self.assertEqual(answer("What is 4 minus -12?"), 16)
Exemple #37
0
 def test_multiple_additions(self):
     self.assertEqual(answer("What is 1 plus 1 plus 1?"), 3)
Exemple #38
0
 def test_multiplication(self):
     self.assertEqual(answer("What is -3 multiplied by 25?"), -75)
Exemple #39
0
 def test_multiple_subtraction(self):
     self.assertEqual(answer("What is 20 minus 4 minus 13?"), 3)
Exemple #40
0
 def test_division(self):
     self.assertEqual(answer("What is 33 divided by -3?"), -11)
Exemple #41
0
 def test_multiple_multiplication(self):
     self.assertEqual(
         answer("What is 2 multiplied by -2 multiplied by 3?"), -12)
Exemple #42
0
 def test_multiple_additions(self):
     self.assertEqual(answer("What is 1 plus 1 plus 1?"), 3)
Exemple #43
0
 def test_multiple_division(self):
     self.assertEqual(
         answer("What is -12 divided by 2 divided by -3?"), 2)
Exemple #44
0
 def test_addition_and_subtraction(self):
     self.assertEqual(answer("What is 1 plus 5 minus -2?"), 8)
Exemple #45
0
 def test_non_math_question(self):
     with self.assertRaisesWithMessage(ValueError):
         answer("Who is the President of the United States?")
Exemple #46
0
 def test_multiple_subtraction(self):
     self.assertEqual(answer("What is 20 minus 4 minus 13?"), 3)
Exemple #47
0
 def test_reject_problem_with_no_operands_or_operators(self):
     with self.assertRaisesWithMessage(ValueError):
         answer('What is?')
Exemple #48
0
 def test_subtraction_then_addition(self):
     self.assertEqual(answer("What is 17 minus 6 plus 3?"), 14)
Exemple #49
0
 def test_reject_two_numbers_in_a_row(self):
     with self.assertRaisesWithMessage(ValueError):
         answer('What is 1 plus 2 1?')
Exemple #50
0
 def test_multiple_multiplication(self):
     self.assertEqual(answer("What is 2 multiplied by -2 multiplied by 3?"), -12)
Exemple #51
0
 def test_just_a_number(self):
     self.assertEqual(answer('What is 5?'), 5)
Exemple #52
0
 def test_addition_and_multiplication(self):
     self.assertEqual(answer("What is -3 plus 7 multiplied by -2?"), -8)
Exemple #53
0
 def test_missing_number(self):
     with self.assertRaisesWithMessage(ValueError):
         answer("What is 7 plus multiplied by -2?")
Exemple #54
0
 def test_non_math_question(self):
     with self.assertRaises(ValueError) as err:
         answer("Who is the President of the United States?")
     self.assertEqual(type(err.exception), ValueError)
     self.assertEqual(err.exception.args[0], "unknown operation")