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
评论列表
文章目录