Exemplo n.º 1
0
def index(mmpdb_filename, *args):
    args = ("--quiet", "index", TEST_DATA_FRAGMENTS, "-o",
            mmpdb_filename) + tuple(args)
    try:
        commandline.main(args)
    except SystemExit as err:
        raise AssertionError("SystemExit trying to run %r: %s" % (args, err))
Exemplo n.º 2
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,))
Exemplo n.º 3
0
def loadprops(mmpdb_filename, *args):
    args = ("--quiet", "loadprops", "-p", TEST_DATA_CSV,
            mmpdb_filename) + tuple(args)
    try:
        commandline.main(args)
    except SystemExit as err:
        raise AssertionError("SystemExit trying to run %r: %s" % (args, err))
Exemplo n.º 4
0
def transform(*args):
    args = ("--quiet", "transform", TEST_DATA_MMPDB) + tuple(args)
    with capture_stdout() as stdout:
        try:
            commandline.main(args)
        except SystemExit as err:
            raise AssertionError("SystemExit trying to run %r: %s" %
                                 (args, err))
    return parse_table(stdout.value)
Exemplo n.º 5
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
Exemplo n.º 6
0
def fragment_to_stdout(*args):
    args = ("--quiet", "fragment") + fix_fragment_args(args)

    try:
        with capture_stdout() as stdout:
            commandline.main(args)

        return stdout.value
    except SystemExit as err:
        raise AssertionError("SystemExit trying to run %r: %s" % (args, err))
Exemplo n.º 7
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
Exemplo n.º 8
0
def smifrag(*args):
    args = ("--quiet", "smifrag") + fix_fragment_args(args)
    try:
        with capture_stdout() as stdout:
            commandline.main(args)

        lines = stdout.value.splitlines(False)
        del lines[:3]
        return [[term.strip() for term in line.split("|")] for line in lines]
        #return stdout.value
    except SystemExit as err:
        raise AssertionError("SystemExit trying to run %r: %s" % (args, err))
Exemplo n.º 9
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
Exemplo n.º 10
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