pytest - 读取pytest.ini 配置信息
pytest.ini:
[pytest]
log_cli=True
addopts= -s
conftest.py:
import pytest
# 读取pytest.ini 的配置信息 返回给测试用例
@pytest.fixture()
def getini(pytestconfig):
return [pytestconfig.getini('log_cli'), pytestconfig.getini('addopts')]
test_getini.py:
import pytest
def test_getini(getini): # get_cmdopts: 名字要与conftest.py中用fixture标记的方法保持一致
print(getini)
本文来自博客园,作者:chuangzhou,转载请注明原文链接:https://www.cnblogs.com/czzz/p/16273413.html