test_machinery.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:Projects 作者: it2school 项目源码 文件源码
def __call__(self, parent_class, meth):
        key = (parent_class, meth.__name__)
        if key not in self.memoized:
            parent_module = self.get_parent_module(parent_class)

            module_tags = getattr(parent_module, '__tags__', [])
            class_tags  = getattr(parent_class,  '__tags__', [])

            tags = TAGS_RE.search(inspect.getdoc(meth) or '')
            if tags: test_tags = [t.strip() for t in tags.group(1).split(',')]
            else:    test_tags = []

            combined = set()
            for tags in (module_tags, class_tags, test_tags):
                if not tags: continue

                add    = set([t for t in tags if not t.startswith('-')])
                remove = set([t[1:] for t in tags if t not in add])

                if add:     combined.update(add)
                if remove:  combined.difference_update(remove)

            self.memoized[key] = combined

        return self.memoized[key]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号