Add autospec to modbus mock, in order to use getattr (#51813)

This commit is contained in:
jan iversen 2021-06-17 10:57:20 +02:00 committed by GitHub
parent ee6c77048c
commit 3ba90776c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -97,12 +97,9 @@ async def base_test(
mock_sync = mock.MagicMock()
with mock.patch(
"homeassistant.components.modbus.modbus.ModbusTcpClient", return_value=mock_sync
), mock.patch(
"homeassistant.components.modbus.modbus.ModbusSerialClient",
"homeassistant.components.modbus.modbus.ModbusTcpClient",
autospec=True,
return_value=mock_sync,
), mock.patch(
"homeassistant.components.modbus.modbus.ModbusUdpClient", return_value=mock_sync
):
# Setup inputs for the sensor