我已经编写了在vscode项目中由pytest运行的测试。配置文件.vscode/settings.json允许使用以下命令向pytest传递其他命令行参数:
"python.testing.pytestArgs": [
"test/",
"--exitfirst",
"--verbose"
],
如何将自定义脚本参数传递给测试脚本本身?类似于从命令行调用pytest,如下所示:
pytest --exitfirst --verbose test/ --test_arg1 --test_arg2
Tags:
如果这只是针对调试器,那么您可以在
launch.json
文件的"args"
中指定内容。有关更多详细信息,请参见https://code.visualstudio.com/docs/python/debugging#_args经过多次试验,我终于找到了方法。我需要的是将用户名和密码传递给脚本,以便允许代码登录到测试服务器。我的测试是这样的:
my_module_test.py
conftest.py
然后在我的设置文件中,我可以使用:
.vscode/settings.json
另一种方法是使用pytest.ini文件:
pytest.ini
相关问题 更多 >
编程相关推荐