pset.py 文件源码

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

项目:speccer 作者: bensimner 项目源码 文件源码
def unittest_wrapper(depth):
    def _wrapper(pset):
        class NewPSet(pset, unittest.TestCase):
            pass

        for p in NewPSet.__properties__:
            def _f(self, p=p):
                self.depth = depth
                out = speccer.spec(depth, getattr(self, p), output=False)
                # raise other exceptions out
                if isinstance(out, speccer.UnrelatedException):
                    raise out.reason

                self.assertIsInstance(out, speccer.clauses.Success)

            setattr(NewPSet, 'test_{}'.format(p), _f)

        NewPSet.__name__ = pset.__name__
        NewPSet.__qualname__ = pset.__qualname__
        NewPSet.__module__ = pset.__module__
        return NewPSet
    return _wrapper
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号