【发布时间】:2018-07-05 19:47:53
【问题描述】:
我正在尝试使 Visual Studio Code 单元测试的自运行 feature 工作。 我最近对我的 Python 项目的目录结构进行了更改,之前是这样的:
myproje\
domain\
__init__.py
repositories\
tests\
__init__.py
guardstest.py
utils\
__init__.py
guards.py
web\
我的单元测试设置是这样的:
"python.unitTest.unittestArgs": [
"-v",
"-s",
"tests",
"-p",
"*test*.py"
]
修改后的项目结构如下:
myprojet\
app\
controllers\
__init__.py
models\
__init__.py
entities.py
enums.py
tests\
res\
image1.png
image2.png
__init__.py
guardstest.py
utils\
__init__.py
guards.py
views\
static\
templnates\
__init__.py
uml\
之后,扩展程序不再发现我的测试。我尝试将'-s'参数更改为"./app/tests"、".tests"、"./tests"、"app/tests"、"/app/tests"、"app.tests",但未成功。
【问题讨论】:
-
你在说什么?你的 IDE 是什么?
-
我正在尝试使 Visual Studio Code 单元测试的自运行 feature 工作。我正在使用 Visual Studio 代码
-
Visual Studio Code 对于测试发现的错误输出有点守口如瓶。要获得实际的错误消息,请在 CLI
python -m unittest discover -v -s tests/ -p '*_test.py'上手动运行它(适应您的目录和命名模式)。 -
有趣的是,当我运行“python -m unittest discover -v -s tests/ -p '*_test.py'”时,我所有的测试都运行没有错误,但是 VScode 仍然没有发现它们...
-
python -m unittest discover -v -s tests/ -p '*_test.py'感谢您提供此命令
标签: python visual-studio-code vscode-settings