@@ -149,7 +149,13 @@ def testUdpClientRecv(self):
149149 self .assertEqual (b'' , client ._recv (0 ))
150150 self .assertEqual (b'\x00 ' * 4 , client ._recv (4 ))
151151
152-
152+ def testUdpClientRepr (self ):
153+ client = ModbusUdpClient ()
154+ rep = "<{} at {} socket={}, ipaddr={}, port={}, timeout={}>" .format (
155+ client .__class__ .__name__ , hex (id (client )), client .socket ,
156+ client .host , client .port , client .timeout
157+ )
158+ self .assertEqual (repr (client ), rep )
153159 # -----------------------------------------------------------------------#
154160 # Test TCP Client
155161 # -----------------------------------------------------------------------#
@@ -221,7 +227,13 @@ def testTcpClientRecv(self):
221227 client .socket .timeout = 0.1
222228 self .assertIn (b'\x00 ' , client ._recv (None ))
223229
224-
230+ def testSerialClientRpr (self ):
231+ client = ModbusTcpClient ()
232+ rep = "<{} at {} socket={}, ipaddr={}, port={}, timeout={}>" .format (
233+ client .__class__ .__name__ , hex (id (client )), client .socket ,
234+ client .host , client .port , client .timeout
235+ )
236+ self .assertEqual (repr (client ), rep )
225237
226238 # -----------------------------------------------------------------------#
227239 # Test Serial Client
@@ -327,7 +339,13 @@ def testSerialClientRecv(self):
327339 client .socket .timeout = 0
328340 self .assertEqual (b'' , client ._recv (0 ))
329341
330-
342+ def testSerialClientRepr (self ):
343+ client = ModbusSerialClient ()
344+ rep = "<{} at {} socket={}, method={}, timeout={}>" .format (
345+ client .__class__ .__name__ , hex (id (client )), client .socket ,
346+ client .method , client .timeout
347+ )
348+ self .assertEqual (repr (client ), rep )
331349# ---------------------------------------------------------------------------#
332350# Main
333351# ---------------------------------------------------------------------------#
0 commit comments