到今天为止,测试发现对我来说已经停止了,已经很难设置了,而且我似乎无法修复它。
文件夹结构:
(在src或测试中没有__init__.py文件)
Python扩展设置:
"python.autoComplete.addBrackets": true,
"python.autoComplete.extraPaths": [
"${workspaceRoot}/src"
],
"python.envFile": "${workspaceFolder}/.envFile",
"python.pythonPath": "${workspaceFolder}/.env/bin/python",
"python.unitTest.pyTestArgs": [
"-v", // increase verbosity
"-l", // show locals in tracebacks
"-x", // exit instantly on first error or failed test
"--ff", // run all tests but run the last failures first
"--color=yes" // color terminal output (yes/no/auto)
],
"python.unitTest.pyTestEnabled": true,
"python.unitTest.unittestArgs": [
"*test*.py",
"-p",
"-s",
"-v",
"."
],
"python.venvFolders": [
".env"
],
"python.workspaceSymbols.exclusionPatterns": [
"**/.env/",
"**/site-packages/**",
"_build"
],.envFile = PYTHONPATH=./src/
运行“发现所有测试”时的Python测试日志:
[1m============================= test session starts ==============================[0m
platform darwin -- Python 3.6.4, pytest-3.2.1, py-1.4.34, pluggy-0.4.0
rootdir: [redacted]/src, inifile:
plugins: cov-2.5.1
collected 0 items
[33m[1m========================= no tests ran in 0.05 seconds =========================[0m最后:
PYTHONPATH=./src py.test tests --collect-only
======================================================================================================================== test session starts ========================================================================================================================
platform darwin -- Python 3.6.4, pytest-3.2.1, py-1.4.34, pluggy-0.4.0
rootdir: [redacted, note no src], inifile:
plugins: cov-2.5.1
collected 225 items发布于 2018-06-26 14:09:34
这一点已由唐·贾亚曼本人在“吉突布问题:https://github.com/Microsoft/vscode-python/issues/2047”中回答。
发布于 2019-10-09 02:18:28
对一些人来说可能的解决办法:
当我遇到这种情况时,我的解决办法是查看Python (参见下面),并注意有关ImportError的错误。我修复了这个导入错误,几秒钟后自动发现了测试。
更多信息:要获取Python,请转到左侧侧栏中的“测试”>“运行所有测试”(图标有play按钮和两个烧杯),当您运行它时,您应该(希望)看到两个弹出通知:
单击第二个“查看输出”。
发布于 2018-06-25 08:47:52
我建议将Python扩展降级到2018.5.0。GitHub中有多个问题描述了运行测试(https://github.com/Microsoft/vscode-python/issues)中的问题。
https://stackoverflow.com/questions/51019259
复制相似问题