예제 #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