def test_fails_to_parse_second(self): e = self.assertSimpleParseFailure( combinators.count(5, primitives.match(lambda c: c == "h", {"error!"})), "hello") self.assertEqual("e", e.value) self.assertEqual(list("llo"), list(e.it)) self.assertEqual({"error!"}, e.expected)
def __rmul__(self, n): return Parser(combinators.count(n, self))
def test_fails_to_parse(self): e = self.assertParseFailure( combinators.count(1, primitives.error({"error!"})), "hello") self.assertEqual({"error!"}, e.expected)
def test_parses(self): self.assertParse( combinators.count(5, primitives.any_), list("hello"), "", "hello")