Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a287dbf

Browse files
committedApr 25, 2025·
fix: tickit sim test fixture
Detect start better tickit does not stop cleanly on python 3.12 so kill process
1 parent 1a1633d commit a287dbf

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed
 

‎tests/test_docs_snippets.py

+15-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import glob
22
import runpy
3-
import signal
43
import subprocess
4+
import time
55
from pathlib import Path
6-
from time import sleep
76

87
import pytest
98

@@ -12,21 +11,30 @@
1211

1312
@pytest.fixture(scope="module", autouse=True)
1413
def sim_temperature_controller():
15-
"""Subprocess that runs ``tickit all <config_path>``."""
1614
config_path: str = f"{HERE}/../src/fastcs/demo/simulation/temp_controller.yaml"
17-
proc = subprocess.Popen(
15+
process = subprocess.Popen(
1816
["tickit", "all", config_path],
1917
stdout=subprocess.PIPE,
2018
stderr=subprocess.STDOUT,
2119
text=True,
2220
)
2321

24-
sleep(1)
22+
TIMEOUT = 10
23+
start_time = time.monotonic()
24+
while process.stdout is not None:
25+
line = process.stdout.readline()
26+
if "Temperature controller running" in line:
27+
break
28+
29+
if time.monotonic() - start_time > TIMEOUT:
30+
raise TimeoutError("Simulator did not start in time")
31+
32+
time.sleep(0.1)
2533

2634
yield
2735

28-
proc.send_signal(signal.SIGINT)
29-
print(proc.communicate()[0])
36+
process.kill()
37+
print(process.communicate()[0])
3038

3139

3240
@pytest.mark.parametrize("filename", glob.glob("docs/snippets/*.py", recursive=True))

0 commit comments

Comments
 (0)
Please sign in to comment.