Skip to content

Commit 1471efa

Browse files
Python: make TypeSafe transport tests explicit and close the fake proxy cleanly
1 parent 86949cf commit 1471efa

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

‎python/packages/typesafe/tests/typesafe/test_chat_client.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,9 @@ def handle_request(request: httpx2.Request) -> httpx2.Response:
264264
)
265265

266266
def create_client(**kwargs: Any) -> AsyncTypeSafeClient:
267+
# The connector must leave the SDK's HTTP stack alone so proxy settings still apply.
268+
assert "transport" not in kwargs
269+
assert "http_client" not in kwargs
267270
return AsyncTypeSafeClient(**kwargs, transport=httpx2.MockTransport(handle_request))
268271

269272
monkeypatch.setattr(
@@ -302,6 +305,7 @@ async def handle_proxy_request(reader: asyncio.StreamReader, writer: asyncio.Str
302305
)
303306
await writer.drain()
304307
writer.close()
308+
await writer.wait_closed()
305309

306310
proxy = await asyncio.start_server(handle_proxy_request, "127.0.0.1", 0)
307311
proxy_port = proxy.sockets[0].getsockname()[1]

0 commit comments

Comments
 (0)