2017-08-09 52 views
4

相关联。在Pytest所有的测试,我们有pytest --markers命令,它会列出所有可使用的标记。清单与给定的标记在Pytest

但是,我没有看到命令列出与x标记关联的测试。文档似乎没有涵盖这个,所以Pytest中有这种可能性吗?

回答

6

使用--collect-only一起选择中与-m <marker>

$ py.test --collect-only -m x 
=========================== test session starts =========================== 
platform linux -- Python 3.6.2, pytest-3.2.1, py-1.4.34, pluggy-0.4.0 
rootdir: /home/they4kman/.virtualenvs/tmp-e1f1b42d6ff9bfa/src, inifile: 
collected 3 items               
<Module 'test_markers.py'> 
    <Function 'test_x'> 

====================== no tests ran in 0.00 seconds ======================= 
+1

这完美地工作,谢谢! – Wunderbread