From 7b241592b07e42a0ed924173ab9d8689408acd64 Mon Sep 17 00:00:00 2001 From: Thibault Pelletier Date: Fri, 17 Jan 2025 14:16:58 +0100 Subject: [PATCH] fix(test): fix test helpers for Windows * Use full current python path when running Selenium server python process * Fix port parsing in xprocess logs for Windows * Add option to disable log prints to avoid test clutter --- trame_client/utils/testing.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/trame_client/utils/testing.py b/trame_client/utils/testing.py index f6ef715..8933e55 100644 --- a/trame_client/utils/testing.py +++ b/trame_client/utils/testing.py @@ -1,4 +1,5 @@ import json +import sys from pathlib import Path from xprocess import ProcessStarter from PIL import Image @@ -11,19 +12,23 @@ class TrameServerMonitor: - def __init__(self, log_path): + def __init__(self, log_path, do_print_log_lines=True): self._log_path = log_path self._last_state = {} self.port = 0 + self.do_print_log_lines = do_print_log_lines self.update() def update(self): last_state_line = "STATE: {}" with open(self._log_path, "r") as f: for line in f.readlines(): - print(line) + if self.do_print_log_lines: + print(line) if "SERVER_PORT:" in line: self.port = int(line[13:]) + elif "Network:" in line: + self.port = int(line.split(":")[-1].split("/")[0]) if line[:7] == "STATE: ": last_state_line = line @@ -69,7 +74,7 @@ class Starter(ProcessStarter): # command to start process args = [ - "python3", + Path(sys.executable).as_posix(), str(self.root_path / server_path), "--server", "--host",