def skip(reason):
"""A decorator to unconditionally skip a test:
.. code-block:: python
@datatest.skip('Not finished collecting raw data.')
class TestSumTotals(datatest.DataTestCase):
def test_totals(self):
...
"""
def decorator(test_item):
if not isinstance(test_item, type):
orig_item = test_item # <- Not in unittest.skip()
@functools.wraps(test_item)
def skip_wrapper(*args, **kwargs):
raise unittest.SkipTest(reason)
test_item = skip_wrapper
test_item._wrapped = orig_item # <- Not in unittest.skip()
test_item.__unittest_skip__ = True
test_item.__unittest_skip_why__ = reason
return test_item
return decorator
评论列表
文章目录