Skip to content

Commit fad7e01

Browse files
committed
Move imports to top of file in Unicode test
Consolidate multiprocessing, socket, and time imports at the top of the file rather than importing them locally within fixtures. The imports within run_unicode_server remain as they must be available in the separate process context.
1 parent 0884269 commit fad7e01

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

tests/client/test_http_unicode.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
(server→client and client→server) using the streamable HTTP transport.
66
"""
77

8+
import multiprocessing
9+
import socket
10+
import time
811
from collections.abc import Generator
912

1013
import pytest
@@ -144,8 +147,6 @@ async def lifespan(app: Starlette) -> AsyncGenerator[None, None]:
144147
@pytest.fixture
145148
def unicode_server_port() -> int:
146149
"""Find an available port for the Unicode test server."""
147-
import socket
148-
149150
with socket.socket() as s:
150151
s.bind(("127.0.0.1", 0))
151152
return s.getsockname()[1]
@@ -154,10 +155,6 @@ def unicode_server_port() -> int:
154155
@pytest.fixture
155156
def running_unicode_server(unicode_server_port: int) -> Generator[str, None, None]:
156157
"""Start a Unicode test server in a separate process."""
157-
import multiprocessing
158-
import socket
159-
import time
160-
161158
proc = multiprocessing.Process(target=run_unicode_server, kwargs={"port": unicode_server_port}, daemon=True)
162159
proc.start()
163160

0 commit comments

Comments
 (0)