t020fuzzy.py

来自「antlr最新版本V3源代码」· Python 代码 · 共 41 行

PY
41
字号
import osimport sysimport antlr3import testbaseimport unittestfrom cStringIO import StringIOimport difflibclass t020fuzzy(testbase.ANTLRTest):    def setUp(self):        self.compileGrammar()            def testValid(self):        inputPath = os.path.splitext(__file__)[0] + '.input'        stream = antlr3.StringStream(open(inputPath).read())        lexer = self.getLexer(stream)        while True:            token = lexer.nextToken()            if token.type == antlr3.EOF:                break        output = lexer.output.getvalue()        outputPath = os.path.splitext(__file__)[0] + '.output'        testOutput = open(outputPath).read()        success = (output == testOutput)        if not success:            d = difflib.Differ()            r = d.compare(output.splitlines(1), testOutput.splitlines(1))            self.fail(                ''.join([l.encode('ascii', 'backslashreplace') for l in r])                )if __name__ == '__main__':    unittest.main()

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?