2222from pymodbus .datastore .store import ModbusSequentialDataBlock
2323from pymodbus .exceptions import ConnectionException , ModbusException , ModbusIOException
2424from pymodbus .pdu import ModbusRequest
25- from pymodbus .transport import CommType
25+ from pymodbus .transport import CommParams , CommType
2626
2727
2828BASE_PORT = 6500
@@ -281,6 +281,7 @@ async def test_client_modbusbaseclient():
281281 host = "localhost" ,
282282 port = BASE_PORT + 1 ,
283283 CommType = CommType .TCP ,
284+ comm_params = CommParams (),
284285 )
285286 client .register (pdu_bit_read .ReadCoilsResponse )
286287 assert str (client )
@@ -316,6 +317,7 @@ async def test_client_base_async():
316317 host = "localhost" ,
317318 port = BASE_PORT + 2 ,
318319 CommType = CommType .TCP ,
320+ comm_params = CommParams (),
319321 ) as client :
320322 str (client )
321323 p_connect .return_value = asyncio .Future ()
@@ -327,7 +329,8 @@ async def test_client_base_async():
327329@pytest .mark .skip ()
328330async def test_client_protocol_receiver ():
329331 """Test the client protocol data received."""
330- base = ModbusBaseClient (FramerType .SOCKET )
332+ base = ModbusBaseClient (FramerType .SOCKET , comm_params = CommParams (),
333+ )
331334 transport = mock .MagicMock ()
332335 base .ctx .connection_made (transport )
333336 assert base .transport == transport
@@ -349,7 +352,8 @@ async def test_client_protocol_receiver():
349352@pytest .mark .skip ()
350353async def test_client_protocol_response ():
351354 """Test the udp client protocol builds responses."""
352- base = ModbusBaseClient (FramerType .SOCKET )
355+ base = ModbusBaseClient (FramerType .SOCKET , comm_params = CommParams (),
356+ )
353357 response = base .build_response (0x00 ) # pylint: disable=protected-access
354358 excp = response .exception ()
355359 assert isinstance (excp , ConnectionException )
@@ -363,7 +367,8 @@ async def test_client_protocol_response():
363367async def test_client_protocol_handler ():
364368 """Test the client protocol handles responses."""
365369 base = ModbusBaseClient (
366- FramerType .ASCII , host = "localhost" , port = + 3 , CommType = CommType .TCP
370+ FramerType .ASCII , host = "localhost" , port = + 3 , CommType = CommType .TCP , comm_params = CommParams (),
371+
367372 )
368373 transport = mock .MagicMock ()
369374 base .ctx .connection_made (transport = transport )
@@ -411,7 +416,8 @@ def close(self):
411416
412417async def test_client_protocol_execute ():
413418 """Test the client protocol execute method."""
414- base = ModbusBaseClient (FramerType .SOCKET , host = "127.0.0.1" )
419+ base = ModbusBaseClient (FramerType .SOCKET , host = "127.0.0.1" , comm_params = CommParams (),
420+ )
415421 request = pdu_bit_read .ReadCoilsRequest (1 , 1 )
416422 transport = MockTransport (base , request )
417423 base .ctx .connection_made (transport = transport )
@@ -422,7 +428,8 @@ async def test_client_protocol_execute():
422428
423429async def test_client_execute_broadcast ():
424430 """Test the client protocol execute method."""
425- base = ModbusBaseClient (FramerType .SOCKET , host = "127.0.0.1" )
431+ base = ModbusBaseClient (FramerType .SOCKET , host = "127.0.0.1" , comm_params = CommParams (),
432+ )
426433 base .broadcast_enable = True
427434 request = pdu_bit_read .ReadCoilsRequest (1 , 1 )
428435 transport = MockTransport (base , request )
@@ -432,7 +439,8 @@ async def test_client_execute_broadcast():
432439
433440async def test_client_protocol_retry ():
434441 """Test the client protocol execute method with retries."""
435- base = ModbusBaseClient (FramerType .SOCKET , host = "127.0.0.1" , timeout = 0.1 )
442+ base = ModbusBaseClient (FramerType .SOCKET , host = "127.0.0.1" , timeout = 0.1 , comm_params = CommParams (),
443+ )
436444 request = pdu_bit_read .ReadCoilsRequest (1 , 1 )
437445 transport = MockTransport (base , request , retries = 2 )
438446 base .ctx .connection_made (transport = transport )
@@ -445,7 +453,8 @@ async def test_client_protocol_retry():
445453
446454async def test_client_protocol_timeout ():
447455 """Test the client protocol execute method with timeout."""
448- base = ModbusBaseClient (FramerType .SOCKET , host = "127.0.0.1" , timeout = 0.1 , retries = 2 )
456+ base = ModbusBaseClient (FramerType .SOCKET , host = "127.0.0.1" , timeout = 0.1 , retries = 2 , comm_params = CommParams (),
457+ )
449458 # Avoid creating do_reconnect() task
450459 base .ctx .connection_lost = mock .MagicMock ()
451460 request = pdu_bit_read .ReadCoilsRequest (1 , 1 )
@@ -645,7 +654,8 @@ def test_client_mixin_convert_fail():
645654
646655async def test_client_build_response ():
647656 """Test fail of build_response."""
648- client = ModbusBaseClient (FramerType .RTU )
657+ client = ModbusBaseClient (FramerType .RTU , comm_params = CommParams (),
658+ )
649659 with pytest .raises (ConnectionException ):
650660 await client .build_response (ModbusRequest (0 , 0 , 0 , False ))
651661
0 commit comments