小编r-b*_*eer的帖子

vscode-python 在错误的目录中运行 pytest,导致相对路径变得混乱

使用 pytest 和 vscode-python 我想运行之前使用 unittest 框架实现的测试。

因此,我在相应的目录中使用 pytest 成功运行了测试tests

pytest
Run Code Online (Sandbox Code Playgroud)

我还设置了 vscode-python 并成功测试了几乎所有测试。

但是,这些从子目录加载数据的测试tests/data会失败,因为 vscode-python 似乎从测试目录之外的另一个目录运行 pytest tests

abc/
|-- tests/
    |-- test_function.py
    |-- data/
Run Code Online (Sandbox Code Playgroud)

如何设置 vscode-python,以便成功读取已实施的测试中的所有数据文件?

python-3.x vscode-python

10
推荐指数
1
解决办法
2万
查看次数

标签 统计

python-3.x ×1

vscode-python ×1