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

Python 有没有办法只标记一个要运行的测试?,python,pytest,Python,Pytest,我正在调试一个失败的测试。有没有办法只标记一个要运行的测试 比如: @pytest.only # it doesn't work def test_some_test(): ... 您可以使用pytest.mark标记测试。标记是动态创建的,因此您几乎可以选择任何名称 例如在tt.py中: import pytest @pytest.mark.one_test def test_foo(): assert 1 == 1 def test_bar(): assert 2

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

比如:

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

您可以使用
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

pytest tt.py -m one_test

======================= test session starts =========================

platform darwin -- Python 3.6.3, pytest-3.6.1, py-1.5.3, pluggy-0.6.0

rootdir: /Users/foobarna/workspace/random, inifile:
collected 2 items / 1 deselected

tt.py .
[100%]

============= 1 passed, 1 deselected in 0.04 seconds ================

我的问题不同。我知道模式过滤。但它是笨拙的<代码>仅几乎无处不在