您是否知道是否可以使用pytest python API收集所有pytest节点ID(如此处所示)?
我已经找到了--collect-only
pytest的参数,但是我不知道如何使用python获取输出?
提前致谢 !
如果要以编程方式访问nodeid,最好是编写一个小插件,将其存储在测试集合中。例:
import pytest
class NodeidsCollector:
def pytest_collection_modifyitems(self, items):
self.nodeids = [item.nodeid for item in items]
def main():
collector = NodeidsCollector()
pytest.main(['--collect-only'], plugins=[collector])
# use collector.nodeids now
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句