我正在尝试使用nosetests来运行我的项目中的所有测试用例。
我 cd 到我的项目目录:
cd projects/myproject
然后我这样做:
nosetests
哪些输出:
----------------------------------------------------------------------
Ran 0 tests in 0.001s
OK
在projects/myproject 中,我有一个名为Encode 的包,在该包中我有带有测试的Test 目录:
Encode/
__init__.py
Video.py
Ffmpeg.py
Test/
VideoTest.py
FfmpegTest.py
为什么nosetests 没有检测到我的单元测试?我的所有单元测试类都扩展了unittest.TestCase。
最佳答案
来自nose docs :
Any function or class that matches the configured testMatch regular expression ((?:^|[\b_\.-])[Tt]est) by default – that is, has test or Test at a word boundary or following a - or _) and lives in a module that also matches that expression will be run as a test.
找不到您的测试,因为您的文件名与模式不匹配。例如,将它们更改为 Video_Test.py 或 Test_Video.py。顺便说一句:他们有这样的驼峰命名也很奇怪,但这不会阻止他们工作。
关于python - 无法使用 Nose 测试运行测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11263343/