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)
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)
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'))