From 6984a1df248534ea2fe22cf70f09f9f319b178af Mon Sep 17 00:00:00 2001 From: polischuks Date: Sat, 15 Feb 2025 14:47:43 +0200 Subject: [PATCH] Refactor python_executor to use is_windows utility for OS checks --- hstest/testing/execution/process/python_executor.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hstest/testing/execution/process/python_executor.py b/hstest/testing/execution/process/python_executor.py index a983476..32d3721 100644 --- a/hstest/testing/execution/process/python_executor.py +++ b/hstest/testing/execution/process/python_executor.py @@ -2,6 +2,7 @@ import os +from hstest.common.os_utils import is_windows from hstest.testing.execution.process_executor import ProcessExecutor from hstest.testing.execution.searcher.python_searcher import PythonSearcher @@ -10,12 +11,12 @@ class PythonExecutor(ProcessExecutor): def __init__(self, source_name: str | None = None) -> None: super().__init__(PythonSearcher().find(source_name)) # Set UTF-8 encoding for Python I/O on Windows - if os.name == "nt": + if is_windows(): os.environ["PYTHONIOENCODING"] = "utf8" def _execution_command(self, *args: str): cmd = ["python"] - if os.name == "nt": # Works on all Windows versions (32/64 bit) + if is_windows(): # Works on all Windows versions (32/64 bit) # Set UTF-8 encoding for stdin/stdout on Windows cmd.extend(["-X", "utf8"]) cmd.extend(["-u", self.runnable.file, *list(args)])