'Get test methods with sources from base package with metadata'

def get_tests(self):

    tests = {}
    for module_name in self._modules_search():
        tests[module_name] = {}
        module = importlib.import_module(module_name)
        source_path = '.'.join((os.path.splitext(module.__file__)[0], 'py'))
        with open(source_path, 'r') as f:
            source = f.read()
        tests[module_name]['source_path'] = source_path
        tests[module_name]['tests'] = {}
        source_parsed = ast.parse(source)
        tests[module_name]['ast'] = source_parsed
        tests[module_name]['import_valid'] = (hasattr(module, DECORATOR_MODULE) and inspect.ismodule(getattr(module, DECORATOR_MODULE)))
        test_cases = (node for node in source_parsed.body if self._is_test_case(module, node))
        for node in test_cases:
            for subnode in filter(self._is_test_method, node.body):
                test_name = ('%s.%s' % (node.name, subnode.name))
                tests[module_name]['tests'][test_name] = subnode
    return tests
