From 08d76ee3ada2c5ab5d909649c0e0cddcd79c4256 Mon Sep 17 00:00:00 2001 From: jan iversen Date: Tue, 16 Dec 2025 10:34:08 +0100 Subject: [PATCH] Correct check_ci.sh. --- check_ci.sh | 2 +- examples/package_test_tool.py | 23 +++++++++++------------ 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/check_ci.sh b/check_ci.sh index b00381b95..717187f6e 100755 --- a/check_ci.sh +++ b/check_ci.sh @@ -8,6 +8,6 @@ trap 'echo "\"${last_command}\" command filed with exit code $?."' EXIT codespell ruff check --fix --exit-non-zero-on-fix . pylint --recursive=y examples pymodbus test -zuban pymodbus examples +zuban check pymodbus examples pytest -x --cov --numprocesses auto echo "Ready to push" diff --git a/examples/package_test_tool.py b/examples/package_test_tool.py index c7e3a9191..6e6eb88d6 100755 --- a/examples/package_test_tool.py +++ b/examples/package_test_tool.py @@ -102,32 +102,30 @@ def callback_new_connection(self) -> ModbusProtocol: new_stub.stub_handle_data = self.stub_handle_data return new_stub - -TEST_PORT = 5004 - class ClientTester: # pylint: disable=too-few-public-methods """Main program.""" + TEST_PORT = 5004 + def __init__(self, comm: CommType): """Initialize runtime tester.""" - global TEST_PORT # pylint: disable=global-statement self.comm = comm host = NULLMODEM_HOST self.client: modbusClient.AsyncModbusTcpClient | modbusClient.AsyncModbusSerialClient if comm == CommType.TCP: self.client = modbusClient.AsyncModbusTcpClient( host, - port=TEST_PORT, + port=self.TEST_PORT, ) else: # if comm == CommType.SERIAL: - host = f"{NULLMODEM_HOST}:{TEST_PORT}" + host = f"{NULLMODEM_HOST}:{self.TEST_PORT}" self.client = modbusClient.AsyncModbusSerialClient( host, ) server_params = self.client.ctx.comm_params.copy() - server_params.source_address = (host, TEST_PORT) + server_params.source_address = (host, self.TEST_PORT) self.stub = TransportStub(server_params, True, simulate_server) - TEST_PORT += 1 + self.TEST_PORT += 1 async def run(self): @@ -146,9 +144,10 @@ async def run(self): class ServerTester: # pylint: disable=too-few-public-methods """Main program.""" + TEST_PORT = 5020 + def __init__(self, comm: CommType): """Initialize runtime tester.""" - global TEST_PORT # pylint: disable=global-statement self.comm = comm self.store = ModbusDeviceContext( di=ModbusSequentialDataBlock(0, [17] * 100), @@ -166,19 +165,19 @@ def __init__(self, comm: CommType): self.context, framer=FramerType.SOCKET, identity=self.identity, - address=(NULLMODEM_HOST, TEST_PORT), + address=(NULLMODEM_HOST, self.TEST_PORT), ) else: # if comm == CommType.SERIAL: self.server = modbusServer.ModbusSerialServer( self.context, framer=FramerType.SOCKET, identity=self.identity, - port=f"{NULLMODEM_HOST}:{TEST_PORT}", + port=f"{NULLMODEM_HOST}:{self.TEST_PORT}", ) client_params = self.server.comm_params.copy() client_params.timeout_connect = 1.0 self.stub = TransportStub(client_params, False, simulate_client) - TEST_PORT += 1 + self.TEST_PORT += 1 async def run(self):