简体   繁体   English

VS Code pytest 在工作区中找不到任何测试

[英]VS Code pytest can't find any tests in workspace

I am trying to migrate my python project from pycharm to vs code.我正在尝试将我的 python 项目从 pycharm 迁移到 vs 代码。 I have PyTest setup in vs-code but none of the tests are being found even though running pytest from the command line works fine.我在 vs-code 中设置了 PyTest,但即使从命令行运行 pytest 工作正常,也没有找到任何测试。 On the left side in the "Testing" section where should be project tests I am getting the error: "ModuleNotFoundError: No module named 'YADAYADA'", maybe somebody knows how to fix this?在应该是项目测试的“测试”部分的左侧,我收到错误:“ModuleNotFoundError:没有名为‘YADAYADA’的模块”,也许有人知道如何解决这个问题?

I have tried to add init .py file to every folder and subfolder我试图将init .py 文件添加到每个文件夹和子文件夹

Vscode uses the currently open folder as the workspace. Vscode 使用当前打开的文件夹作为工作区。 You need to open your project folder with vscode.你需要用 vscode 打开你的项目文件夹。 In addition, you also need to install necessary extensions for it, such as Python .另外,你还需要为它安装必要的扩展,比如Python

Tests can be configured in the test panel on the left.可以在左侧的测试面板中配置测试。 You can also use Python: Configure Tests from the command palette at any time.您还可以随时使用Python: Configure Tests

在此处输入图像描述

Read the documentation for details.阅读文档了解详情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM