blob: fc4aafeef23be2682c4fba0c448a5f6b7c909e69 [file] [log] [blame]
A R Karthick861da962017-02-08 16:21:36 -08001import inspect
2import unittest
3import json
4import os
5from nose.tools import assert_not_equal
6
7def setup_module(module):
A.R Karthick99044822017-02-09 14:04:20 -08008 class_test = None
A R Karthick861da962017-02-08 16:21:36 -08009 for name, obj in inspect.getmembers(module):
10 if inspect.isclass(obj) and issubclass(obj, unittest.TestCase):
11 if obj.__name__.endswith('exchange'):
A.R Karthick99044822017-02-09 14:04:20 -080012 class_test = obj
A R Karthick861da962017-02-08 16:21:36 -080013 break
14 else:
A.R Karthick99044822017-02-09 14:04:20 -080015 class_test = obj
A R Karthick861da962017-02-08 16:21:36 -080016
A.R Karthick99044822017-02-09 14:04:20 -080017 assert_not_equal(class_test, None)
18 module_name = module.__name__.split('.')[-1]
A R Karthick861da962017-02-08 16:21:36 -080019 cfg = '{}.json'.format(module_name)
20 module_config = os.path.join(os.path.dirname(module.__file__), cfg)
21 if os.access(module_config, os.F_OK):
22 with open(module_config) as f:
23 json_data = json.load(f)
24 for k, v in json_data.iteritems():
A.R Karthick99044822017-02-09 14:04:20 -080025 setattr(class_test, k, v)