From 9ba12e5496c49f48f40ad52e816641dfdbb0474e Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Fri, 7 Jul 2023 22:13:00 +0200 Subject: test: add some basic command-line usage tests --- test/py/lib/process.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'test/py/lib') diff --git a/test/py/lib/process.py b/test/py/lib/process.py index 3436280..d478c32 100644 --- a/test/py/lib/process.py +++ b/test/py/lib/process.py @@ -89,6 +89,9 @@ class CmdLine: def run(self, *argv): return Process.run(*self.argv, *argv) + def try_run(self, *argv): + return Process.try_run(*self.argv, *argv) + @contextmanager def run_async(self, *argv): with Process(self, *argv) as process: @@ -146,6 +149,13 @@ class Process(subprocess.Popen): Process._log_process_end(argv, ec, output) raise + @staticmethod + def try_run(*args, **kwargs): + try: + return 0, Process.run(*args, **kwargs) + except subprocess.CalledProcessError as e: + return e.returncode, e.stdout + def __init__(self, cmd_line, *args): self.cmd_line = cmd_line -- cgit v1.2.3