2020class TestEventGateway :
2121 test_client = TestGateway .create_test_module (controllers = [EventGateway ])
2222
23- async def test_socket_connection_work (self ):
23+ async def test_socket_connection_work (self , unused_tcp_port ):
2424 my_response_message = []
2525 connected_called = False
2626 disconnected_called = False
2727
28- async with self .test_client .run_with_server () as ctx :
28+ async with self .test_client .run_with_server (port = unused_tcp_port ) as ctx :
2929
3030 @ctx .sio .event
3131 async def my_response (message ):
@@ -52,11 +52,11 @@ async def connect(*args):
5252 ]
5353 assert disconnected_called and connected_called
5454
55- async def test_broadcast_work (self ):
55+ async def test_broadcast_work (self , unused_tcp_port ):
5656 sio_1_response_message = []
5757 sio_2_response_message = []
5858
59- async with self .test_client .run_with_server () as ctx :
59+ async with self .test_client .run_with_server (port = unused_tcp_port ) as ctx :
6060 ctx_2 = ctx .new_socket_client_context ()
6161
6262 @ctx .sio .on ("my_response" )
@@ -94,10 +94,10 @@ async def my_response_case_2(message):
9494class TestGatewayWithGuards :
9595 test_client = TestGateway .create_test_module (controllers = [GatewayWithGuards ])
9696
97- async def test_socket_connection_work (self ):
97+ async def test_socket_connection_work (self , unused_tcp_port ):
9898 my_response_message = []
9999
100- async with self .test_client .run_with_server () as ctx :
100+ async with self .test_client .run_with_server (port = unused_tcp_port ) as ctx :
101101
102102 @ctx .sio .event
103103 async def my_response (message ):
@@ -113,10 +113,10 @@ async def my_response(message):
113113 {"auth-key" : "supersecret" , "data" : "Testing Broadcast" }
114114 ]
115115
116- async def test_event_with_header_work (self ):
116+ async def test_event_with_header_work (self , unused_tcp_port ):
117117 my_response_message = []
118118
119- async with self .test_client .run_with_server () as ctx :
119+ async with self .test_client .run_with_server (port = unused_tcp_port ) as ctx :
120120
121121 @ctx .sio .event
122122 async def my_response (message ):
@@ -132,10 +132,10 @@ async def my_response(message):
132132 {"data" : "Testing Broadcast" , "x_auth_key" : "supersecret" }
133133 ]
134134
135- async def test_event_with_plain_response (self ):
135+ async def test_event_with_plain_response (self , unused_tcp_port ):
136136 my_response_message = []
137137
138- async with self .test_client .run_with_server () as ctx :
138+ async with self .test_client .run_with_server (port = unused_tcp_port ) as ctx :
139139
140140 @ctx .sio .on ("my_plain_response" )
141141 async def message_receive (message ):
@@ -151,10 +151,10 @@ async def message_receive(message):
151151 {"data" : "Testing Broadcast" , "x_auth_key" : "supersecret" }
152152 ]
153153
154- async def test_failed_to_connect (self ):
154+ async def test_failed_to_connect (self , unused_tcp_port ):
155155 my_response_message = []
156156
157- async with self .test_client .run_with_server () as ctx :
157+ async with self .test_client .run_with_server (port = unused_tcp_port ) as ctx :
158158 ctx = typing .cast (RunWithServerContext , ctx )
159159
160160 @ctx .sio .on ("error" )
@@ -169,10 +169,10 @@ async def error(message):
169169
170170 assert my_response_message == [{"code" : 1011 , "reason" : "Authorization Failed" }]
171171
172- async def test_failed_process_message_sent (self ):
172+ async def test_failed_process_message_sent (self , unused_tcp_port ):
173173 my_response_message = []
174174
175- async with self .test_client .run_with_server () as ctx :
175+ async with self .test_client .run_with_server (port = unused_tcp_port ) as ctx :
176176 ctx = typing .cast (RunWithServerContext , ctx )
177177
178178 @ctx .sio .on ("error" )
@@ -224,13 +224,15 @@ class TestGatewayExceptions:
224224 ),
225225 ],
226226 )
227- async def test_exception_handling_works_debug_true_or_false (self , debug , result ):
227+ async def test_exception_handling_works_debug_true_or_false (
228+ self , debug , result , unused_tcp_port
229+ ):
228230 test_client = TestGateway .create_test_module (
229231 controllers = [GatewayOthers ], config_module = {"DEBUG" : debug }
230232 )
231233 my_response_message = []
232234
233- async with test_client .run_with_server () as ctx :
235+ async with test_client .run_with_server (port = unused_tcp_port ) as ctx :
234236 ctx = typing .cast (RunWithServerContext , ctx )
235237 ctx2 = ctx .new_socket_client_context ()
236238
@@ -253,11 +255,11 @@ async def error_2(message):
253255
254256 assert my_response_message == result
255257
256- async def test_message_with_extra_args (self ):
258+ async def test_message_with_extra_args (self , unused_tcp_port ):
257259 test_client = TestGateway .create_test_module (controllers = [GatewayOthers ])
258260 my_response_message = []
259261
260- async with test_client .run_with_server () as ctx :
262+ async with test_client .run_with_server (port = unused_tcp_port ) as ctx :
261263 ctx = typing .cast (RunWithServerContext , ctx )
262264
263265 @ctx .sio .on ("error" )
0 commit comments