def test_parse_multiplication_fails(self): """ In this test division by zero is checked since it's not possible to make this operation, parse_multiplication() method should raise a 'MathParseException' so that it can be handled in the rest of the code """ expr = '5/0' p = Parser(expr) try: p.parse_multiplication() except MathParseException: raised = True self.assertTrue(raised)
def test_parse_multiplication(self): """ parse_multiplication() method is checked in this test in order to assure it works properly, given a multiplication operation contained in a string as a input param """ expr = '1/(5+7)' p = Parser(expr) result = p.parse_multiplication() self.assertEqual(result, 1.0/12.0)