1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
#!/usr/bin/env python
import unittest
from pymodbus.client.sync import ModbusTcpClient
from pymodbus.datastore.remote import RemoteSlaveContext
from base_context import ContextRunner
class RemoteSlaveContextTest(ContextRunner, unittest.TestCase):
"""
These are the integration tests for using the redis
slave context.
"""
def setUp(self):
""" Initializes the test environment """
self.context = RemoteSlaveContext(client=None) # for the log statment
self.initialize(["../tools/reference/diagslave", "-m", "tcp", "-p", "12345"])
self.client = ModbusTcpClient(port=12345)
self.context = RemoteSlaveContext(client=self.client)
def tearDown(self):
""" Cleans up the test environment """
self.client.close()
self.shutdown()
# --------------------------------------------------------------------------- #
# Main
# --------------------------------------------------------------------------- #
if __name__ == "__main__":
unittest.main()
|