Пример #1
0
def find_test_modules(module_path):
    module_dir = os.path.realpath(os.path.dirname(module_path))
    scope = {}

    for filename in os.listdir(module_dir):
        if not (filename.startswith('test_') and filename.endswith('.py')):
            continue

        project_root = get_project_root()

        module_name = filename.replace('.py', '')
        module_path = '{0}.{1}'.format(
            module_dir.replace(project_root, ''), module_name).replace('/', '.')[1:]

        module = import_module(module_path)

        for name in dir(module):
            item = getattr(module, name)

            try:
                if issubclass(item, TestCase):
                    scope[name] = item
            except TypeError:
                pass

    return scope
Пример #2
0
 def env_path(self):
     project_root = get_project_root()        
     return os.path.join(project_root, ENV_FILE)