def test_parse_number_fails_2(self): """ In this test parse_number() method is checked. It should return an exception since there are more than one dot in the given string """ expr = '345..5' p = Parser(expr) try: p.parse_number() except MathParseException: raised = True self.assertTrue(raised)
def test_parse_number(self): """ This test aims to check if the parse_number() function defined inside Parse class is able to correctly detect numbers :return: """ expr = ' 5' p = Parser(expr) self.assertEqual(p.parse_number(), 5) expr = '345.5' p2 = Parser(expr) self.assertEqual(p2.parse_number(), 345.5)
def test_parse_number_fails_1(self): """ In this test parse_number() method is checked. It should return an exception since the string passed as attribute doesn't represent a number """ expr = '(' p = Parser(expr) try: p.parse_number() except MathParseException: raised = True self.assertTrue(raised)