示例#1
0
文件: tests.py 项目: syhpoon/xyzcmd
    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)
示例#2
0
文件: tests.py 项目: syhpoon/xyzcmd
    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)
示例#3
0
文件: tests.py 项目: syhpoon/xyzcmd
    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