-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Description
pymodbus/test/test_client_sync.py
Lines 192 to 203 in 152ad8d
| def test_tcp_client_register(self): | |
| """Test tcp client.""" | |
| class CustomRequest: # pylint: disable=too-few-public-methods | |
| """Dummy custom request.""" | |
| function_code = 79 | |
| client = ModbusTcpClient("127.0.0.1") | |
| client.framer = mock.Mock() | |
| client.register(CustomRequest) | |
| assert client.framer.decoder.register.called_once_with(CustomRequest) |
pymodbus/test/test_client_sync.py
Lines 281 to 292 in 152ad8d
| def test_tls_client_register(self): | |
| """Test tls client.""" | |
| class CustomeRequest: # pylint: disable=too-few-public-methods | |
| """Dummy custom request.""" | |
| function_code = 79 | |
| client = ModbusTlsClient("127.0.0.1") | |
| client.framer = mock.Mock() | |
| client.register(CustomeRequest) | |
| assert client.framer.decoder.register.called_once_with(CustomeRequest) |
These tests will always pass. even if the call were changed to client.register('WTFBBQ'), client.register(NotImplementedError), or anything else.
(1) mock.called_once_with() does not exist. It should be mock.assert_called_once_with().
(2) The assert at the beginning of the line will pass on any truth-y value, including a mocked method.
Metadata
Metadata
Assignees
Labels
No labels