初始化钩子
目录
初始化钩子
-
调用插件和conftest.py文件的初始化挂钩,添加命令行选项
import pytest def pytest_addoption(parser:pytest.Parser): parser.addoption("--xxxx",default="xxxx",name="weburl") @pytest.fixture() def get_weburl(pytestconfig): return pytestconfig.getoption("xxxx")
-
使用pytest_configure钩子在conftest文件中注册标签
def pytest_configure(config): config.addinivalue_line( "markers", "env(name): mark test to run only on named environment" )
-
pytest_unconfigure测试结束的时候执行
def pytest_unconfigure(config): pass