Sco*_*ott 7 pytest visual-studio-code
我试图让我的单元测试显示在 VSCode 的测试资源管理器中,但它似乎不起作用。测试发现不会因输出中出现任何错误而失败,但也不会显示我的任何测试。
这是我正在使用的存储库,您可以在那里看到文件结构。
这可能与我使用诗歌来管理我的虚拟环境有任何关系,也可能没有任何关系,尽管我确信 python 解释器设置正确。pytest我可以通过运行或在我的基本目录中手动让我的测试完美运行poetry run pytest。__init__.py我的测试目录中确实有一个空目录。另外值得注意的是,我在 WSL 2 上的 Ubuntu 中运行。
我通过以下过程设置了这个环境:
pip install poetrypoetry install这是我的工作区设置.json:
{
"restructuredtext.confPath": "${workspaceFolder}/docs/source",
"python.testing.pytestEnabled": true,
}
Run Code Online (Sandbox Code Playgroud)
以下是我尝试刷新测试时显示的输出:
~/.cache/pypoetry/virtualenvs/monaco-bfS1OgpY-py3.9/bin/python ~/.vscode-server/extensions/ms-python.python-2021.11.1422169775/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir ~/coding/monaco -s --cache-clear
cwd: ~/coding/monaco
Run Code Online (Sandbox Code Playgroud)
如果我在终端中手动运行上述命令,它会打印出一个大字典,看起来它描述了我所有的测试。(下面,被截断,但它会这样持续一段时间)。
[{"rootid": ".", "root": "/mnt/c/Users/Scott/Documents/Documents/Coding/monaco", "parents": [{"id": "./tests", "kind": "folder", "name": "tests", "parentid": ".", "relpath": "./tests"}, {"id": "./tests/test_MCCase.py", "kind": "file", "name": "test_MCCase.py", "parentid": "./tests", "relpath": "./tests/test_MCCase.py"}, {"id": "./tests/test_MCSim.py", "kind": "file", "name": "test_MCSim.py", "parentid": "./tests", "relpath": "./tests/test_MCSim.py"}, {"id": "./tests/test_MCSim_io.py", "kind": "file", "name": "test_MCSim_io.py", "parentid": "./tests", "relpath": "./tests/test_MCSim_io.py"}, {"id": "./tests/test_MCVal.py", "kind": "file", "name": "test_MCVal.py", "parentid": "./tests", "relpath": "./tests/test_MCVal.py"},
Run Code Online (Sandbox Code Playgroud)
表面看来,要么
无论如何,为了帮助您,我们需要更多信息。
> ~/.cache/pypoetry/virtualenvs/myproject-bfS1OgpY-py3.9/bin/python ~/.vscode-server/extensions/ms-python.python-2021.11.1422169775/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir ~/coding/myproject/tests -s --cache-clear .
cwd: ~/coding/myproject/tests
Run Code Online (Sandbox Code Playgroud)
即使是胡言乱语
| 归档时间: |
|
| 查看次数: |
7908 次 |
| 最近记录: |