def test_AddingLabel(self): # Arrange parser1 = bpr.LParser('x') parser2 = bpr.LParser(',') parser = cmb.sep_by(parser1, parser2, label='Parser: lor') parser_default_label = cmb.sep_by(parser1, parser2) # Assert self.assertEqual(parser.label, 'Parser: lor') self.assertEqual(parser_default_label.label, 'x[,x]+')
def test_FailureCase(self): # Arrange txt1 = 'ABC' sep = bpr.LParser(",") item = stp.parse_lowercases() parser = cmb.sep_by(item, sep) # Act result1 = parser(txt1) expected1 = res.Failure('error') # Assert self.assertEqual(result1, expected1)
def test_SuccessCase(self): # Arrange txt1 = 'abc,def,ghi' txt2 = 'abc' txt3 = '' sep = bpr.LParser(",") item = stp.parse_lowercases() parser = cmb.sep_by(item, sep) # Act result1 = parser(txt1) expected1 = res.Success(('abc,def,ghi', '')) result2 = parser(txt2) expected2 = res.Success(('abc', '')) result3 = parser(txt3) expected3 = res.Success(('', '')) # Assert self.assertEqual(result1, expected1) self.assertEqual(result2, expected2) self.assertEqual(result3, expected3)