From 8eb06fadba884a3a40385f40b1c1645d2fa1816b Mon Sep 17 00:00:00 2001 From: James Hilliard Date: Sat, 20 Jul 2024 10:39:46 -0600 Subject: [PATCH] simpler and more robust ModbusRequest test --- test/test_transaction.py | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/test/test_transaction.py b/test/test_transaction.py index b2e3b376e1..f5c1638d1b 100755 --- a/test/test_transaction.py +++ b/test/test_transaction.py @@ -186,33 +186,20 @@ def test_transaction_manager_tid(self): def test_get_transaction_manager_transaction(self): """Test the getting a transaction from the transaction manager.""" - - class Request: # pylint: disable=too-few-public-methods - """Request.""" - self._manager.reset() - handle = Request() - handle.transaction_id = ( # pylint: disable=attribute-defined-outside-init - self._manager.getNextTID() + handle = ModbusRequest( + 0, self._manager.getNextTID(), 0, False ) - handle.message = b"testing" # pylint: disable=attribute-defined-outside-init self._manager.addTransaction(handle) result = self._manager.getTransaction(handle.transaction_id) - assert handle.message == result.message + assert handle is result def test_delete_transaction_manager_transaction(self): """Test deleting a transaction from the dict transaction manager.""" - - class Request: # pylint: disable=too-few-public-methods - """Request.""" - self._manager.reset() - handle = Request() - handle.transaction_id = ( # pylint: disable=attribute-defined-outside-init - self._manager.getNextTID() + handle = ModbusRequest( + 0, self._manager.getNextTID(), 0, False ) - handle.message = b"testing" # pylint: disable=attribute-defined-outside-init - self._manager.addTransaction(handle) self._manager.delTransaction(handle.transaction_id) assert not self._manager.getTransaction(handle.transaction_id)