【发布时间】:2019-09-14 05:10:10
【问题描述】:
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 的?您是否在您的虚拟环境中使用与您的 settings.json 中指定的参数相同的 pytest?
-
从命令行我只是在 VS Code 使用的同一个虚拟环境中执行
pytest tests。 -
是的,我还在 VSCode 中从终端运行 pytest,然后发现它,以便之后我可以从 GUI 运行它。
标签: python visual-studio-code pytest vscode-settings