有些用例需要在特定环境下执行,所以就要用掉用例跳过
1.无条件跳过:@unittest.skip
@unittest.skip("无条件跳过")
def test_skip(self):
ret=calc("1-1")
self.assertEqual(2,ret)
print("跳过的用例")
结果:不会执行
2.有条件跳过:@unittest.skipIf
# 假如当前系统位window或者MacOS,就跳过
@unittest.skipIf(sys.platform in ["win32","darwin"],"本地case,跳过")
def test_skip_if(self):
ret = calc("1-1")
self.assertEqual(2, ret)
print("跳过的用例")