Skip to content

Commit

Permalink
Refactor python_executor to use is_windows utility for OS checks
Browse files Browse the repository at this point in the history
  • Loading branch information
polischuks committed Feb 15, 2025
1 parent fe5aa52 commit 6984a1d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions hstest/testing/execution/process/python_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)])
Expand Down

0 comments on commit 6984a1d

Please sign in to comment.