> 文章列表 > 关于request.config.getoption的使用方式

关于request.config.getoption的使用方式

关于request.config.getoption的使用方式

request.config.getoption()是pytest框架中的一个方法,用于获取命令行选项的值。它的使用方式如下:

  1. 在pytest命令行中添加自定义选项,例如:
pytest --env=test

这里添加了一个名为--env的自定义选项,并将其值设置为test

  1. 在测试用例中调用request.config.getoption()方法来获取选项的值,例如:
def test_example(request):env = request.config.getoption(\'--env\', default