def capture_with_argv(*argv): sys.argv = argv stdout, stderr = StringIO(), StringIO() oldstdout, oldstderr = sys.stdout, sys.stderr sys.stdout = stdout sys.stderr = stderr try: cli.main() except SystemExit: pass sys.stdout = oldstdout sys.stderr = oldstderr stdout.seek(0) stderr.seek(0) return stdout.read(), stderr.read()
def capture_with_argv(*argv): # only used in capture_json_with_argv() sys.argv = argv stdout, stderr = StringIO(), StringIO() oldstdout, oldstderr = sys.stdout, sys.stderr sys.stdout = stdout sys.stderr = stderr try: cli.main() except SystemExit: pass sys.stdout = oldstdout sys.stderr = oldstderr stdout.seek(0) stderr.seek(0) stdout, stderr = stdout.read(), stderr.read() print(stdout) print(stderr, file=sys.stderr) return stdout, strip_expected(stderr)
def capture_with_argv(*argv): sys.argv = argv stdout, stderr = StringIO(), StringIO() oldstdout, oldstderr = sys.stdout, sys.stderr sys.stdout = stdout sys.stderr = stderr try: cli.main() except SystemExit: pass sys.stdout = oldstdout sys.stderr = oldstderr stdout.seek(0) stderr.seek(0) stdout, stderr = stdout.read(), stderr.read() print('>>>>>>>>> stdout >>>>>>>>>') print(stdout) print('>>>>>>>>> stderr >>>>>>>>>') print(stderr) print('>>>>>>>>>') return stdout, strip_expected(stderr)