我正在尝试调试pytest。我想注入一个环境变量。下面是我设置launch.json的方法
{
"type": "python",
"request": "test",
"name": "pytest",
"console": "integratedTerminal",
"env": {
"ENV_VAR":"RandomStuff"
}
},但似乎当我开始调试的时候。我没有看到env变量被注入,因此我期望该env变量的测试失败。
我也注意到错误
Could not load unit test config from launch.json发布于 2020-11-01 14:23:46
我真的不知道如何用Vscode修复“单元”测试调试。但是使用Pytest可以调用像python -m pytest <test file>(https://docs.pytest.org/en/stable/usage.html#cmdline)这样的测试,这意味着可以像模块一样配置Vscode
"configurations": [
{
"name": "Python: Module",
"type": "python",
"request": "launch",
"module": "pytest",
"args": ["--headful","--capture=no", "--html=report.html"],
}这对于调试python测试已经足够好了。然后,还可以插入环境变量
"env": {
"ENV_VAR":"RandomStuff"
}https://stackoverflow.com/questions/64592226
复制相似问题