有没有办法只标记一个测试运行?

时间:2018-06-14 11:35:50

标签: python pytest

我正在调试一个失败的测试。有没有办法只标记一个要运行的测试?

类似的东西:

@pytest.only # it doesn't work
def test_some_test():
  ...

1 个答案:

答案 0 :(得分:1)

您可以使用OrderItems标记您的测试。标记是动态创建的,因此您几乎可以选择任何名称。 Here is a link to docs.

例如pytest.mark

tt.py

然后使用import pytest @pytest.mark.one_test def test_foo(): assert 1 == 1 def test_bar(): assert 2 == 2 enter code here

运行
pytest tt.py -m one_test
相关问题