diff --git a/bin/tests/system/conftest.py b/bin/tests/system/conftest.py index 2a36a6eb62..390312c258 100644 --- a/bin/tests/system/conftest.py +++ b/bin/tests/system/conftest.py @@ -364,28 +364,25 @@ def _run_script( # pylint: disable=too-many-arguments raise FileNotFoundError(f"script {script} not found in {cwd}") logger.debug("running script: %s %s %s", interpreter, script, " ".join(args)) logger.debug(" workdir: %s", cwd) - stdout = b"" returncode = 1 - try: - proc = subprocess.run( - [interpreter, script] + args, - env=env, - check=True, - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT, - ) - except subprocess.CalledProcessError as exc: - stdout = exc.stdout - returncode = exc.returncode - raise exc - else: - stdout = proc.stdout - returncode = proc.returncode - finally: - if stdout: - for line in stdout.decode().splitlines(): - logger.debug(" %s", line) - logger.debug(" exited with %d", returncode) + + cmd = [interpreter, script] + args + proc = subprocess.Popen( + cmd, + env=env, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + bufsize=1, + universal_newlines=True + ) + if proc.stdout: + for line in proc.stdout: + logger.info(" %s", line.rstrip('\n')) + proc.communicate() + returncode = proc.returncode + if returncode: + raise subprocess.CalledProcessError(returncode, cmd) + logger.debug(" exited with %d", returncode) return proc @pytest.fixture(scope="module")