33# pylint:disable=redefined-outer-name
44
55import logging
6- from typing import AsyncIterable , Awaitable , Callable , Optional
6+ from typing import AsyncIterable , Awaitable , Callable
77from uuid import uuid4
88
99import pytest
@@ -25,8 +25,8 @@ def _create() -> str:
2525
2626
2727@pytest .fixture ()
28- def socketio_url_factory (client ) -> Callable [[Optional [ TestClient ] ], str ]:
29- def _create (client_override : Optional [ TestClient ] = None ) -> str :
28+ def socketio_url_factory (client ) -> Callable [[TestClient | None ], str ]:
29+ def _create (client_override : TestClient | None = None ) -> str :
3030 SOCKET_IO_PATH = "/socket.io/"
3131 return str ((client_override or client ).make_url (SOCKET_IO_PATH ))
3232
@@ -36,8 +36,8 @@ def _create(client_override: Optional[TestClient] = None) -> str:
3636@pytest .fixture ()
3737async def security_cookie_factory (
3838 client : TestClient ,
39- ) -> Callable [[Optional [ TestClient ] ], Awaitable [str ]]:
40- async def _create (client_override : Optional [ TestClient ] = None ) -> str :
39+ ) -> Callable [[TestClient | None ], Awaitable [str ]]:
40+ async def _create (client_override : TestClient | None = None ) -> str :
4141 # get the cookie by calling the root entrypoint
4242 resp = await (client_override or client ).get ("/v0/" )
4343 data , error = await assert_status (resp , web .HTTPOk )
@@ -60,14 +60,13 @@ async def socketio_client_factory(
6060 security_cookie_factory : Callable ,
6161 client_session_id_factory : Callable ,
6262) -> AsyncIterable [
63- Callable [[Optional [ str ], Optional [ TestClient ] ], Awaitable [socketio .AsyncClient ]]
63+ Callable [[str | None , TestClient | None ], Awaitable [socketio .AsyncClient ]]
6464]:
6565 clients : list [socketio .AsyncClient ] = []
6666
6767 async def _connect (
68- client_session_id : Optional [ str ] = None , client : Optional [ TestClient ] = None
68+ client_session_id : str | None = None , client : TestClient | None = None
6969 ) -> socketio .AsyncClient :
70-
7170 if client_session_id is None :
7271 client_session_id = client_session_id_factory ()
7372
@@ -86,7 +85,7 @@ async def _connect(
8685 headers .update ({"Cookie" : cookie })
8786
8887 print (f"--> Connecting socketio client to { url } ..." )
89- await sio .connect (url , headers = headers )
88+ await sio .connect (url , headers = headers , wait_timeout = 10 )
9089 assert sio .sid
9190 print ("... connection done" )
9291 clients .append (sio )
0 commit comments