Exemple #1
0
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()
Exemple #2
0
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()
Exemple #3
0
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)
Exemple #4
0
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)
Exemple #5
0
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)
Exemple #6
0
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)