def pytest_addoption(parser):
parser.addoption(" libname", action="append", default=[],
help="name of the tested library")
def pytest_generate_tests(metafunc):
if 'libname' in metafunc.fixturenames:
metafunc.parametrize("libname", metafunc.config.option.libname)
可以使用metafunc并使用
pytest_addoption
和pytest_generate_tests
函数创建conftest.py
文件:在
^{pr2}$tests.py
文件中的函数中,可以使用importlib并请求libname:现在,运行测试时,应提供要测试的模块的名称:
py.test tests.py libname=your_name1
(也可以添加libname=your_name2
)相关问题 更多 >
编程相关推荐