blob: 0e369d99ad295e24c7719b108b49ead53b20bc5f [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):
8 class_found = None
9 for name, obj in inspect.getmembers(module):
10 if inspect.isclass(obj) and issubclass(obj, unittest.TestCase):
11 if obj.__name__.endswith('exchange'):
12 class_found = obj
13 break
14 else:
15 class_found = obj
16
17 assert_not_equal(class_found, None)
18 try:
19 module_name = module.__name__.split('.')[-1]
20 except:
21 module_name = module.__name__
22
23 cfg = '{}.json'.format(module_name)
24 module_config = os.path.join(os.path.dirname(module.__file__), cfg)
25 if os.access(module_config, os.F_OK):
26 with open(module_config) as f:
27 json_data = json.load(f)
28 for k, v in json_data.iteritems():
29 setattr(class_found, k, v)