Fixing test_vms_api test

This commit is contained in:
Qubasa
2023-10-25 13:10:30 +02:00
parent 86790a6282
commit 674d84a43a
5 changed files with 31 additions and 20 deletions

View File

@@ -21,6 +21,7 @@ class Command:
stdout: _FILE = None,
stderr: _FILE = None,
workdir: Optional[Path] = None,
check: Optional[bool] = True,
) -> subprocess.Popen[str]:
env = os.environ.copy()
env.update(extra_env)
@@ -36,6 +37,14 @@ class Command:
cwd=workdir,
)
self.processes.append(p)
if check:
p.wait()
if p.returncode != 0:
aout = p.stdout.read() if p.stdout else ""
bout = p.stderr.read() if p.stderr else ""
raise subprocess.CalledProcessError(
p.returncode, command, output=aout, stderr=bout
)
return p
def terminate(self) -> None: