def testUnmatched(self): """ Test for umatched line """ def cb(mo): return _p = RegexpParser({re.compile("^test line$"): cb}) _src = "NOT a test line" _p.parse(_src)
def testCBFailure(self): """ Test for callback raising exceptions """ def cb(mo): raise XYZValueError(u"Test error") _p = RegexpParser({re.compile("^test line$"): cb}) _src = "test line" _p.parse(_src)
def testCBSuccess(self): """ Test for callback success """ self.res = False def cb(mo): self.res = True _p = RegexpParser({re.compile("^test line$"): cb}) _src = "test line" _p.parse(_src) assert self.res