python - VSCode pytest 测试发现失败
问题描述
Pytest 测试发现失败。用户界面指出:
Test discovery error, please check the configuration settings for the tests
输出窗口状态:
Test Discovery failed:
Error: Traceback (most recent call last):
File "C:\Users\mikep\.vscode\extensions\ms-python.python-2019.4.11987\pythonFiles\testing_tools\run_adapter.py", line 16, in <module>
main(tool, cmd, subargs, toolargs)
File "C:\Users\mikep\.vscode\extensions\ms-python.python-2019.4.11987\pythonFiles\testing_tools\adapter\__main__.py", line 90, in main
parents, result = run(toolargs, **subargs)
File "C:\Users\mikep\.vscode\extensions\ms-python.python-2019.4.11987\pythonFiles\testing_tools\adapter\pytest.py", line 43, in discover
raise Exception('pytest discovery failed (exit code {})'.format(ec))
Exception: pytest discovery failed (exit code 3)
这是我的设置:
{
"python.pythonPath": ".venv\\Scripts\\python.exe",
"python.testing.pyTestArgs": [
"tests"
],
"python.testing.unittestEnabled": false,
"python.testing.nosetestsEnabled": false,
"python.testing.pyTestEnabled": true
}
我可以从命令行成功运行 pytest FWIW。
解决方案
在创建了一个有导入错误的测试后,我花了很长时间试图破译这个无益的错误。在进行任何更深入的故障排除之前,验证您的测试套件是否可以实际执行。
pytest --collect-only
是你的朋友。
推荐阅读
- python - 如何在 Flask Python 的另一个文件中从模型创建表?
- node.js - 无法在 googe home 中启用我的智能家居测试应用程序
- go - 使用反射取消引用结构指针和访问字段
- excel - 复制和删除选定的列表框项目
- praat - Praat:删除节点并使用脚本发布重新合成
- php - 自 PHP 7 起,在使用构造时不支持使用已弃用的 PHP4 样式类构造函数
- wordpress - 为什么 WordPress 使用 1984 年 1 月 11 日作为 Expires 标头的反缓存值?
- python - 加载前 100 行 excel
- c++ - 我编写 netbpm 图像的代码有什么问题?
- sql - SQL:遍历具有来自其他列的值的列