pytest跳过测试skip
import pytest class TestClass: @pytest.mark.skip(reason="跳过") def test_one(self): assert True @pytest.mark.skipif(True,reason="跳过") def test_two(self): assert False def test_three(self): assert True
直接运行看不到跳过原因,这时候可以使用 -rs
pytest -rs test_demo4.py
==== test session starts ====
collected 3 items
test_demo4.py ss. [100%]
=== short test summary info ===
SKIPPED [1] test_demo4.py:9: 跳过
SKIPPED [1] test_demo4.py:4: 跳过
=== 1 passed, 2 skipped in 0.07 seconds ===
本文来自博客园,作者:OTAKU_nicole,转载请注明原文链接:https://www.cnblogs.com/nicole-zhang/p/11139827.html