我对 python 测试相当熟悉,所以这可能是我做错了..
当我运行我的测试时,测试运行器工作正常并且覆盖范围也......但在两者之间我得到一个断言错误:
Traceback (most recent call last):
File "/usr/local/bin/coverage", line 9, in <module>
load_entry_point('coverage==3.5.1', 'console_scripts', 'coverage')()
File "/usr/local/lib/python2.7/dist-packages/coverage/cmdline.py", line 657, in main
status = CoverageScript().command_line(argv)
File "/usr/local/lib/python2.7/dist-packages/coverage/cmdline.py", line 526, in command_line
self.coverage.stop()
File "/usr/local/lib/python2.7/dist-packages/coverage/control.py", line 389, in stop
self.collector.stop()
File "/usr/local/lib/python2.7/dist-packages/coverage/collector.py", line 262, in stop
assert self._collectors[-1] is self
AssertionError
为了让事情变得更加困难,我正在尝试测试一个命令行实用程序。这意味着我必须告诉覆盖范围以覆盖子流程调用。
我想我让这部分工作了,因为覆盖率现在报告正在运行的脚本的覆盖率百分比。但是由于我得到了覆盖工作,所以我无法摆脱 AssertionError。
一些帮助理解出了什么问题将不胜感激。我所有的代码都可以在 github 上找到:
快速运行:
cd /tmp/ && git clone git://github.com/h3/django-duke-client.git
cd django-duke-client && chmod a+x run_tests && ./run_tests
谢谢
更新
我在另一台计算机上运行了测试,得到了相同的 AssertionError .. 加上一个新的 TypeError。测试再次正确运行,即使出现这些错误,覆盖率似乎也能正常工作。
...
Ran 9 tests in 1.324s
OK
Traceback (most recent call last):
File "/usr/local/bin/coverage", line 9, in <module>
load_entry_point('coverage==3.5.1', 'console_scripts', 'coverage')()
File "/usr/local/lib/python2.7/dist-packages/coverage/cmdline.py", line 657, in main
status = CoverageScript().command_line(argv)
File "/usr/local/lib/python2.7/dist-packages/coverage/cmdline.py", line 526, in command_line
self.coverage.stop()
File "/usr/local/lib/python2.7/dist-packages/coverage/control.py", line 389, in stop
self.collector.stop()
File "/usr/local/lib/python2.7/dist-packages/coverage/collector.py", line 262, in stop
assert self._collectors[-1] is self
AssertionError
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "/usr/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/usr/lib/python2.7/multiprocessing/util.py", line 284, in _exit_function
info('process shutting down')
TypeError: 'NoneType' object is not callable
Error in sys.exitfunc:
Traceback (most recent call last):
File "/usr/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/usr/lib/python2.7/multiprocessing/util.py", line 284, in _exit_function
info('process shutting down')
TypeError: 'NoneType' object is not callable
Name Stmts Miss Branch BrPart Cover Missing
------------------------------------------------------------------------------
dukeclient/__init__ 53 53 2 0 4% 1-93
dukeclient/commands/__init__ 41 33 6 2 26% 1-9, 12, 14-15, 17, 24-28, 34-43, 46-63
...