有些用例需要在特定环境下执行,所以就要用掉用例跳过
    1.无条件跳过:@unittest.skip

    1. @unittest.skip("无条件跳过")
    2. def test_skip(self):
    3. ret=calc("1-1")
    4. self.assertEqual(2,ret)
    5. print("跳过的用例")

    结果:不会执行
    image.png

    2.有条件跳过:@unittest.skipIf

    1. # 假如当前系统位window或者MacOS,就跳过
    2. @unittest.skipIf(sys.platform in ["win32","darwin"],"本地case,跳过")
    3. def test_skip_if(self):
    4. ret = calc("1-1")
    5. self.assertEqual(2, ret)
    6. print("跳过的用例")