diff --git a/pymodbus/register_write_message.py b/pymodbus/register_write_message.py index 4ff21ac9c..b49db4901 100644 --- a/pymodbus/register_write_message.py +++ b/pymodbus/register_write_message.py @@ -132,9 +132,11 @@ def __init__(self, address=None, values=None, **kwargs): ''' ModbusRequest.__init__(self, **kwargs) self.address = address - self.values = values or [] - if not hasattr(values, '__iter__'): - self.values = [values] + if values is None: + values = [] + elif not hasattr(values, '__iter__'): + values = [values] + self.values = values self.count = len(self.values) self.byte_count = self.count * 2 diff --git a/test/test_client_sync.py b/test/test_client_sync.py index e03ecaf98..6f118d282 100644 --- a/test/test_client_sync.py +++ b/test/test_client_sync.py @@ -97,7 +97,10 @@ def testUdpClientAddressFamily(self): def testUdpClientConnect(self): ''' Test the Udp client connection method''' with patch.object(socket, 'socket') as mock_method: - mock_method.return_value = object() + class DummySocket(object): + def settimeout(self, *a, **kwa): + pass + mock_method.return_value = DummySocket() client = ModbusUdpClient() self.assertTrue(client.connect()) diff --git a/test/test_payload.py b/test/test_payload.py index 453d82fce..302df5824 100644 --- a/test/test_payload.py +++ b/test/test_payload.py @@ -144,7 +144,7 @@ def testPayloadDecoderRegisterFactory(self): ''' Test the payload decoder reset functionality ''' payload = [1,2,3,4] decoder = BinaryPayloadDecoder.fromRegisters(payload, endian=Endian.Little) - encoded = '\x00\x01\x00\x02\x00\x03\x00\x04' + encoded = '\x01\x00\x02\x00\x03\x00\x04\x00' self.assertEqual(encoded, decoder.decode_string(8)) decoder = BinaryPayloadDecoder.fromRegisters(payload, endian=Endian.Big)