import pytest @pytest.mark.mark1 def test_markA(): assert True @pytest.mark.mark2 def test_markB(): assert True @pytest.mark.mark1 @pytest.mark.mark2 def test_markC(): assert True def test_markD(): assert True
#一个mark不要带引号,带and、or等或两个以上必须双引号 pytest -m mark1 pytest -m "mark1 and mark2" pytest -m "mark1 or mark2" pytest -m "mark1 and not mark2"