classes.py 文件源码

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

项目:pytest-relaxed 作者: bitprophet 项目源码 文件源码
def collect(self):
        # Get whatever our parent picked up as valid test items (given our
        # relaxed name constraints above). It'll be nearly all module contents.
        items = super(SpecModule, self).collect()
        collected = []
        for item in items:
            # Replace Class objects with recursive SpecInstances (via
            # SpecClasses, so we don't lose some bits of parent Class).
            # TODO: this may be way more than is necessary; possible we can
            # recurse & unpack here, as long as we preserve parent/child
            # relationships correctly?
            # NOTE: we could explicitly skip unittest objects here (we'd want
            # them to be handled by pytest's own unittest support) but since
            # those are almost always in test_prefixed_filenames anyways...meh
            if isinstance(item, Class):
                item = SpecClass(item.name, item.parent)
            # TODO: pytest.mark objects (i.e. @pytest.mark.something applied to
            # an entire testcase class) may need special treatment here
            # Collect regardless of whether we replaced the item
            collected.append(item)
        return collected


# NOTE: no need to inherit from RelaxedMixin here as it doesn't do much by
# its lonesome
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号