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)
标签:pytestconfig,读取,fixture,py,getini,pytest,ini 来源: https://www.cnblogs.com/czzz/p/16273413.html