Skip to content

Commit c76b28d

Browse files
committed
refactor(test_1363): eliminate temporary files by using python -c
1 parent 3f3c8ae commit c76b28d

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

tests/issues/test_1363_race_condition_streamable_http.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,20 +126,17 @@ def start_server_process(port: int) -> subprocess.Popen[str]:
126126
"""Start server in a separate process."""
127127
# Create a temporary script to run the server
128128
import os
129-
import tempfile
130129

131-
script_content = f"""
130+
server_code = f"""
132131
import sys
133132
sys.path.insert(0, {repr(os.getcwd())})
134133
from tests.issues.test_1363_race_condition_streamable_http import run_server_with_logging
135134
run_server_with_logging({port})
136135
"""
137136

138-
with tempfile.NamedTemporaryFile(mode="w", suffix=".py", delete=False) as f:
139-
f.write(script_content)
140-
script_path = f.name
141-
142-
process = subprocess.Popen([sys.executable, script_path], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
137+
process = subprocess.Popen(
138+
[sys.executable, "-c", server_code], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True
139+
)
143140

144141
# Wait for server to be running with connection testing (like other tests)
145142
max_attempts = 20

0 commit comments

Comments
 (0)