【发布时间】:2014-03-31 08:05:25
【问题描述】:
我的Python版本不支持
@unittest.skip("demonstrating skipping")
来自Disable individual Python unit tests temporarily,我了解如何使用装饰器来实现这一点,即,
def disabled(f):
def _decorator():
print f.__name__ + ' has been disabled'
return _decorator
@disabled
def testFoo():
'''Foo test case'''
print 'this is foo test case'
testFoo()
但是,装饰器不支持为跳过提供消息。请问我可以知道如何实现这一目标吗?我基本上想要类似的东西
def disabled(f, msg):
def _decorator():
print f.__name__ + ' has been disabled' + msg
return _decorator
@disabled("I want to skip it")
def testFoo():
'''Foo test case'''
print 'this is foo test case'
testFoo()
【问题讨论】:
标签: python unit-testing