Exemplo n.º 1
0
    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)
Exemplo n.º 2
0
    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)
Exemplo n.º 3
0
    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