Ejemplo n.º 1
0
def fragment_fail(*args):
    try:
        with capture_stdout() as stdout, capture_stderr() as stderr:
            commandline.main(("--quiet", "fragment", "--salt-remover",
                              "<none>") + args)
    except SystemExit:
        return stderr.value
    raise AssertionError("Should have failed: %r" % (args, ))
Ejemplo n.º 2
0
def transform_fail(*args):
    args = ("--quiet", "transform", TEST_DATA_MMPDB) + tuple(args)
    with capture_stderr() as stderr:
        try:
            commandline.main(args)
        except SystemExit as err:
            pass
        else:
            raise AssertionError("Should have failed: %r" % (args, ))
    return stderr.value
Ejemplo n.º 3
0
def smifrag_fail(*args):
    args = ("--quiet", "smifrag") + fix_fragment_args(args)
    with capture_stderr() as stderr:
        try:
            commandline.main(args)
        except SystemExit as err:
            pass
        else:
            raise AssertionError("Should have failed: %r" % (args, ))
    return stderr.value
Ejemplo n.º 4
0
def run_failure(cmd):
    if isinstance(cmd, str):
        cmd = cmd.split()

    try:
        with support.capture_stdout() as stdout:
            with support.capture_stderr() as stderr:
                commandline.main(cmd)
    except SystemExit as sys_exit:
        pass
    else:
        raise AssertionError("Failed to fail", cmd)

    return stdout.value, stderr.value
Ejemplo n.º 5
0
def run(cmd, stderr_ok=False):
    if isinstance(cmd, str):
        cmd = cmd.split()

    try:
        with support.capture_stdout() as stdout:
            with support.capture_stderr() as stderr:
                commandline.main(cmd)
    except SystemExit as sys_exit:
        raise AssertionError(("unexpected exit", sys_exit, stderr.value))

    if not stderr_ok and stderr.value:
        print(stderr.value, file=sys.stderr)
        raise AssertionError(("unexpected stderr", cmd, stderr.value))
    return stdout.value, stderr.value