我正在py.test
使用coverage
. 我在使用pytest-cov
测试时遇到问题;当我运行时py.test --cov=my_module --coverage-report=html .
,我的模块中的函数定义将被报告为丢失,即使它们应该在测试中导入模块时执行。常见问题解答中提到了这个问题。
然后这个问题让我尝试只运行coverage
而不是使用pytest-cov
,如下所示:
coverage run --source my_module py.test .
现在我收到了这个错误(我在回溯中只显示了最近的调用):
[long traceback]
File "[…]/python3.3/site-packages/py/test.py", line 4, in <module>
sys.exit(pytest.main())
SystemExit: 0
During handling of the above exception, another exception occurred:
[long traceback]
File "[…]/python3.3/site-packages/coverage/collector.py", line 294, in stop
assert self._collectors[-1] is self
AssertionError
有没有其他人遇到过这个?我怎样才能coverage
正常工作py.test
?