根据平台跳过测试

时间:2017-03-14 09:06:34

标签: nose

是否有办法根据platform跳过单元测试?我有linux特定的nosetests,只使用linux的库,我想跳过我们的mac build。

1 个答案:

答案 0 :(得分:0)

显然,你是这样做的

第一步,创建一个装饰者

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()
相关问题