【发布时间】:2011-02-23 09:20:53
【问题描述】:
Python 的 unittest discover 没有找到我的测试!
我一直在使用鼻子来发现我的单元测试,它工作正常。从我的项目的顶层,如果我运行nosetests,我会得到:
Ran 31 tests in 0.390s
现在 Python 2.7 unittest has discovery,我已经尝试使用
python -m unittest discover
但我明白了
Ran 0 tests in 0.000s
我的目录结构是:
myproj/
reporter/
__init__.py
report.py
[other app modules]
tests/
__init__.py
test-report.py
[other test modules]
你知道为什么 unittest 的发现算法找不到测试吗?
我在 Windows 7 上使用 Python 2.7.1 和鼻子 1.0.0。
【问题讨论】:
-
我刚刚发现如果我将
test-report.py重命名为test_report.py会发现测试。除非有人能对此有所了解,否则我将向 unittest 模块维护者提交错误报告。 -
我很惊讶这在鼻子里有效,因为测试报告是不可导入的。
标签: python unit-testing nose unittest2