11#!/usr/bin/env python3
22import unittest
33from unittest .mock import patch , Mock
4+ import pytest
45
56from pymodbus .client .asynchronous .tornado import (BaseTornadoClient ,
67 AsyncModbusSerialClient , AsyncModbusUDPClient , AsyncModbusTCPClient
1112from pymodbus .exceptions import ConnectionException
1213from pymodbus .transaction import ModbusSocketFramer , ModbusRtuFramer
1314from pymodbus .bit_read_message import ReadCoilsRequest , ReadCoilsResponse
14- from test .conftest import SERIAL_PORT
1515
1616# ---------------------------------------------------------------------------#
1717# Fixture
@@ -166,7 +166,7 @@ def testSerialClientInit(self):
166166 client = AsyncModbusSerialClient (ioloop = schedulers .IO_LOOP ,
167167 framer = ModbusRtuFramer (
168168 ClientDecoder ()),
169- port = SERIAL_PORT )
169+ port = pytest . SERIAL_PORT )
170170 self .assertEqual (0 , len (list (client .transaction )))
171171 self .assertTrue (isinstance (client .framer , ModbusRtuFramer ))
172172
@@ -182,8 +182,8 @@ def testSerialClientConnect(self, mock_serial, mock_seriostream, mock_ioloop):
182182 client = AsyncModbusSerialClient (ioloop = schedulers .IO_LOOP ,
183183 framer = ModbusRtuFramer (
184184 ClientDecoder ()),
185- port = SERIAL_PORT )
186- self .assertTrue (client .port , SERIAL_PORT )
185+ port = pytest . SERIAL_PORT )
186+ self .assertTrue (client .port , pytest . SERIAL_PORT )
187187 self .assertFalse (client ._connected )
188188 client .connect ()
189189 self .assertTrue (client ._connected )
@@ -197,7 +197,7 @@ def testSerialClientDisconnect(self, mock_serial, mock_seriostream, mock_ioloop)
197197 client = AsyncModbusSerialClient (ioloop = schedulers .IO_LOOP ,
198198 framer = ModbusRtuFramer (
199199 ClientDecoder ()),
200- port = SERIAL_PORT )
200+ port = pytest . SERIAL_PORT )
201201 client .connect ()
202202 self .assertTrue (client ._connected )
203203
@@ -217,7 +217,7 @@ def testSerialClientExecute(self, mock_serial, mock_seriostream, mock_ioloop):
217217 client = AsyncModbusSerialClient (ioloop = schedulers .IO_LOOP ,
218218 framer = ModbusRtuFramer (
219219 ClientDecoder ()),
220- port = SERIAL_PORT ,
220+ port = pytest . SERIAL_PORT ,
221221 timeout = 0 )
222222 client .connect ()
223223 client .stream = Mock ()
@@ -237,7 +237,7 @@ def testSerialClientHandleResponse(self, mock_serial, mock_seriostream, mock_iol
237237 client = AsyncModbusSerialClient (ioloop = schedulers .IO_LOOP ,
238238 framer = ModbusRtuFramer (
239239 ClientDecoder ()),
240- port = SERIAL_PORT )
240+ port = pytest . SERIAL_PORT )
241241 client .connect ()
242242 out = []
243243 reply = ReadCoilsRequest (1 , 1 )
@@ -261,7 +261,7 @@ def testSerialClientBuildResponse(self, mock_serial, mock_seriostream, mock_iolo
261261 client = AsyncModbusSerialClient (ioloop = schedulers .IO_LOOP ,
262262 framer = ModbusRtuFramer (
263263 ClientDecoder ()),
264- port = SERIAL_PORT )
264+ port = pytest . SERIAL_PORT )
265265 self .assertEqual (0 , len (list (client .transaction )))
266266
267267 def handle_failure (failure ):
0 commit comments