def test_AddingLabel(self): # Arrange parser1 = bpr.LParser('l') parser2 = bpr.LParser('o') parser = cmb.leftparser(parser1, parser2, label='Parser: lor') parser_defualt_label = cmb.leftparser(parser1, parser2) # Assert self.assertEqual(parser.label, 'Parser: lor') self.assertEqual(parser_defualt_label.label, 'lo')
def test_FailureCase(self): # Arrange txt = '123abc lorem ipsum' parser_l = stp.parse_lowercases() parser_r = stp.parse_digits() parser = cmb.leftparser(parser_l, parser_r) # Act result = parser(txt) expected = res.Failure('error') # Assert self.assertEqual(result, expected)
def test_SuccessCase(self): # Arrange txt = 'abc123 lorem ipsum' parser_l = stp.parse_lowercases() parser_r = stp.parse_digits() parser = cmb.leftparser(parser_l, parser_r) # Act result = parser(txt) expected = res.Success(('abc', ' lorem ipsum')) # Assert self.assertEqual(result, expected)