def test_end(self): """ L{OMetaBase.rule_end} matches the end of input and raises L{ParseError} if input is left. """ o = OMetaBase("abc") exc = self.assertRaises(ParseError, o.rule_end) self.assertEqual(exc, ParseError(o.input, 1, None)) o.many(o.rule_anything) self.assertEqual(o.rule_end(), (True, ParseError("abc", 3, None)))
def test_many(self): """ L{OMetaBase.many} returns a list of parsed values and the error that caused the end of the loop. """ data = "ooops" o = OMetaBase(data) self.assertEqual(o.many(lambda: o.rule_exactly("o")), (["o"] * 3, ParseError(o.input, 3, expected(None, "o"))))
def test_many(self): """ L{OMetaBase.many} returns a list of parsed values and the error that caused the end of the loop. """ data = "ooops" o = OMetaBase(data) self.assertEqual( o.many(lambda: o.rule_exactly('o')), (['o'] * 3, ParseError(o.input, 3, expected(None, 'o'))))