gpt4 book ai didi

python - VS Code 未发现 Python 单元测试测试

转载 作者:行者123 更新时间:2023-12-03 20:53:26 36 4
gpt4 key购买 nike

有很多类似的问题(例如 123456 ,...)但没有一个能通过单元测试发现问题shell 提示),而这些问题的解决方案对我不起作用。

当我跑 Python: Discover Tests在 Visual Studio Code 中出现错误

No tests discovered, please check the configuration settings for the tests.



我的 settings.json 文件看起来像这样
{
"python.testing.unittestArgs": [
"--verbose",
"--start-directory",
"./preprocessing/",
"--pattern",
"test_*.py"
],
"python.testing.pytestEnabled": false,
"python.testing.nosetestsEnabled": false,
"python.testing.unittestEnabled": true
}

但我知道单元测试是可发现的,因为如果我从项目的根目录运行此命令,所有测试都会被发现并运行:
python -m unittest discover --verbose --start-directory "./preprocessing/" --pattern "test_*.py"

我的测试显然可以被 Python 的 unittest 框架发现,但 VS Code 没有找到它们。我该如何解决这个问题?

最佳答案

我会尝试在没有 --verbose 的情况下运行.这是没有必要的,因为扩展正在为你做发现,而且我敢打赌它的额外输出会破坏某些东西。

关于python - VS Code 未发现 Python 单元测试测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61894694/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com