def checkPathForPattern(self, path, patterns): # note: look for </html> can ensure cgi did not abort in error buf = fileutil.aStringIO() app_httpserver.handlePath(path, buf) buf.seek(0) p = patterns_tester.checkPatterns(buf, patterns) self.assert_(not p, 'Test failed path:%s\n pattern not found: %s%s' % (path, p, patterns_tester.showFile(buf, 'out')) )
def checkPathForPattern(self, path, patterns, nopattern=None): # note: look for </html> can ensure cgi did not abort in error buf = fileutil.aStringIO() app_httpserver.handlePath(path, buf) buf.seek(0) p = patterns_tester.checkPatterns(buf.read(), patterns, nopattern) # BUG: p can also be nopattern. In this case the msg should be 'pattern found!' self.assert_( not p, "Test failed path:%s\n pattern not found: %s%s" % (path, p, patterns_tester.showFile(buf, "out")) )
def main(): buf = fileutil.aStringIO() sys.stdout = buf try: app_httpserver.main() finally: sys.stdout = sys.__stdout__ buf.seek(0) fp = file('1.html','wb') fix_link(buf,fp) fp.close() print 'See output in 1.html' # what's wrong with opera? webbrowser.open("1.html")
def _run_url(self, path): """ Invoke the URL and return the response HTTP message """ buf = fileutil.aStringIO() app_httpserver.handlePath(path, buf) data = buf.getvalue() return data.decode('utf-8')