コード例 #1
0
ファイル: cases.py プロジェクト: kalkin/nanolp
    def runTest(self, *args):
        shfile = change_ext(self.filename, '.sh')
        args = [sys.executable, script_path("nlp.py")]
        if os.path.exists(shfile):
            # XXX no spaces in path!!!!
            args = args + core.fread23(shfile).split()
        else:
            args = args + ["-i", self.filename]
        proc = subprocess.Popen(args, stderr=subprocess.PIPE)
        exitcode = proc.wait()
        stderrbuf = core.bytestostr23(proc.stderr.read()).strip('\n')

        if exitcode != 0 or len(stderrbuf) != 0:
            err = os.path.splitext(self.filename)[0] + '.stderr'
            if os.path.exists(err):
                errbuf = readfile(err)
                self.assertRegexpMatches(stderrbuf, errbuf, msgfmt('unexpected exception'))
            else:
                self.fail('Exit with 1, stderr="%s"'%stderrbuf)
コード例 #2
0
    def runTest(self, *args):
        shfile = change_ext(self.filename, '.sh')
        args = [sys.executable, script_path("nlp.py")]
        if os.path.exists(shfile):
            # XXX no spaces in path!!!!
            args = args + core.fread23(shfile).split()
        else:
            args = args + ["-i", self.filename]
        proc = subprocess.Popen(args, stderr=subprocess.PIPE)
        exitcode = proc.wait()
        stderrbuf = core.bytestostr23(proc.stderr.read()).strip('\n')

        if exitcode != 0 or len(stderrbuf) != 0:
            err = os.path.splitext(self.filename)[0] + '.stderr'
            if os.path.exists(err):
                errbuf = readfile(err)
                self.assertRegexpMatches(stderrbuf, errbuf,
                                         msgfmt('unexpected exception'))
            else:
                self.fail('Exit with 1, stderr="%s"' % stderrbuf)
コード例 #3
0
ファイル: parsers.py プロジェクト: kalkin/nanolp
 def readfile(self, file):
     """Return text of document"""
     with zipfile.ZipFile(file) as zip:
         #return zip.read('content.xml').decode('utf8')
         return core.bytestostr23(zip.read('content.xml'))
コード例 #4
0
ファイル: parsers.py プロジェクト: kalkin/nanolp
 def readfile(self, file):
     """Return text of document"""
     with zipfile.ZipFile(file) as zip:
         #return zip.read('content.xml').decode('utf8')
         return core.bytestostr23(zip.read('content.xml'))