From f09ca81a616c30cf40dacc18b6dd1c285c8b2bb6 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Tue, 14 Oct 2025 23:02:30 +0200 Subject: [PATCH] run_command function for tests adjusted --- tests/test_compile.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/test_compile.py b/tests/test_compile.py index e05500c..2470c87 100644 --- a/tests/test_compile.py +++ b/tests/test_compile.py @@ -5,12 +5,10 @@ import struct from copapy import binwrite -def run_command(command: list[str], encoding: str = 'utf8') -> str: - process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - output, error = process.communicate() - - assert not error, f"\n -Error occurred: {error.decode(encoding)}\n -Output: {output.decode(encoding)}" - return output.decode(encoding) +def run_command(command: list[str]) -> str: + result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='utf8', check=False) + assert result.returncode == 0, f"\n -Error occurred: {result.stderr}\n -Output: {result.stdout}" + return result.stdout def test_example():