def test_evaluate_divide_by_zero(self): """ In case of divide by zero it should return None for that operator node """ input_string_list = ('2 / 0', '1 + (2 / 0)') for input_string in input_string_list: root_node = build_tree(input_string) with self.assertRaises(EvaluationError): evaluate(root_node)
def test_evaluate_non_digit_token(self): input_string = 'A + (B * C)' root_node = build_tree(input_string) with self.assertRaises(EvaluationError): evaluate(root_node)
def test_evaluate(self): for input_string_tup in self.input_string_list: input_string, expected_result = input_string_tup root_node = build_tree(input_string) self.assertEqual(evaluate(root_node), expected_result)