如何在 vscode 中使用 pytest 测试文件夹中的文件?

How to test a file within a folder with pytest in vscode?

我将 Pycharm 社区 IDE 换成了 VScode IDE,因为 Pycharm 不支持 Jupyter Notebook。我几乎在 IDE 中配置了所有我喜欢的细节,但我真的陷入其中。

VScode 在文件夹中找不到测试,找不到测试。

Test discovery error, please check the configuration settings for the tests

当测试文件不在文件夹中时它会找到它,这是一个"project"的结构,没关系,因为测试文件不在文件夹中:

Folder Structure tests structure 我想把它放在一个文件夹里 =)

非常感谢。

我在另一个随机问题的评论中发现了解决此问题的方法。

因为我们有一个文件夹test,所以...就是添加一个initi.py文件,就这么简单:

|__.pytest_cache
|__Main folder
   core.py
   something.py
|__Tests folder
   |__pycache__
   __init__.py
   test_core.py
   test_something.py

谢谢。