VScode python unittest 测试发现问题

VScode python unittest test discover issue

我可以 运行 从 cmd

我所有的测试
(venv) PS D:_projects\xxx> python -m unittest discover -s .\tests\ -p 'test*.py' -b
...................................
----------------------------------------------------------------------
Ran 35 tests in 0.426s

OK

但 VScode 未发现任何测试(使用相同的测试配置设置和虚拟环境)

    "python.testing.unittestArgs": [
        "-v",
        "-s",
        "./tests",
        "-p",
        "test*.py"
    ],

我确信它在过去有效。据我所知,我没有更改任何设置。

这是我的版本VScode

你有什么要检查的提示吗?

有几件事要尝试:

  1. 完成 VSCode 中配置测试的过程。键入 ctrl+shift+p,然后搜索“Python: Configure Tests”。
  2. 查看 VSCode 中的测试输出在发现测试时显示的内容。
  3. 确保 __init__.py 文件包含在您的项目文件夹中,甚至可能包含在测试文件夹中(即使测试通常不需要这样做)。我之前注意到这里有奇怪的行为,但不记得确切的修复方法。