Skip to content

Commit

Permalink
fix(test): fix test helpers for Windows
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Thibault-Pelletier committed Jan 17, 2025
1 parent 15c968d commit 7b24159
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions trame_client/utils/testing.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import sys
from pathlib import Path
from xprocess import ProcessStarter
from PIL import Image
Expand All @@ -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

Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 7b24159

Please sign in to comment.