【发布时间】:2017-03-14 09:06:34
【问题描述】:
有没有办法根据platform 跳过单元测试?我有 linux 特定的鼻子测试,它们只使用 linux 库,我想在我们的 mac 构建中跳过。
【问题讨论】:
标签: nose
有没有办法根据platform 跳过单元测试?我有 linux 特定的鼻子测试,它们只使用 linux 库,我想在我们的 mac 构建中跳过。
【问题讨论】:
标签: nose
显然,你是这样做的
第一步,创建一个装饰器
def skip_if(condition):
"""Conditionally skips a test"""
def wrapper(f):
f.__test__ = not condition
return f
return wrapper
第二步,在你的情况下使用sys.platform
import sys
@skip_if(sys.platform == "linux")
def test_linux_only()
linus_torvalds()
【讨论】: