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,))
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)
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))
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))
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
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