File: database-slave-context.py

package info (click to toggle)
pymodbus 1.2.0%2Bgit20151013-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,084 kB
  • ctags: 2,155
  • sloc: python: 14,717; makefile: 86
file content (29 lines) | stat: -rw-r--r-- 964 bytes parent folder | download | duplicates (2)
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, os
from pymodbus.datastore.database import DatabaseSlaveContext
from base_context import ContextRunner

class DatabaseSlaveContextTest(ContextRunner, unittest.TestCase):
    '''
    These are the integration tests for using the redis
    slave context.
    '''
    __database = 'sqlite:///pymodbus-test.db'

    def setUp(self):
        ''' Initializes the test environment '''
        path = './' + self.__database.split('///')[1]
        if os.path.exists(path): os.remove(path)
        self.context = DatabaseSlaveContext(database=self.__database)
        self.initialize()

    def tearDown(self):
        ''' Cleans up the test environment '''
        self.context._connection.close()
        self.shutdown()

#---------------------------------------------------------------------------#
# Main
#---------------------------------------------------------------------------#
if __name__ == "__main__":
    unittest.main()