擅长:python、mysql、java
<p>您可以使用pytest标记一些测试,并使用-k arg跳过或包含它们</p>
<P>例如,考虑以下测试,</P>
<pre><code>import pytest
def test_a():
assert True
@pytest.mark.never_run
def test_b():
assert True
def test_c():
assert True
@pytest.mark.never_run
def test_d():
assert True
</code></pre>
<p>您可以像这样运行pytest来运行所有测试</p>
<pre><code>pytest
</code></pre>
<p>要跳过标记的测试,可以像这样运行pytest</p>
<pre><code>pytest -m "not never_run"
</code></pre>
<p>如果要单独运行标记的测试</p>
<pre><code>pytest -m "never_run"
</code></pre>