Python鼻子测试(实际上错误来自Mox)每行输出一个字符一个错误(带有行号!)
|
我最近开始将Nose用于单元测试。它非常好,除了有时在发生错误时会以一种非常奇怪的方式打印出错误信息。它将它分成每行1个字符,然后用行号打印出来。有谁知道如何解决这个问题?
....F...............
======================================================================
FAIL: accounts.tests.testaccountserver.test_create_account_writes_an_account_to_the_store
----------------------------------------------------------------------
Traceback (most recent call last):
File \"/home/tom/envs/myappshare/lib/python2.7/site-packages/nose/case.py\", line 187, in runTest
self.test(*self.arg)
File \"/media/Shared/Dropbox/jobs/myapp/myappshare/src/accounts/tests/testaccountserver.py\", line 102, in test_create_account_writes_an_account_to_the_store
mox.VerifyAll()
File \"/home/tom/envs/myappshare/lib/python2.7/site-packages/mox.py\", line 286, in VerifyAll
mock_obj._Verify()
File \"/home/tom/envs/myappshare/lib/python2.7/site-packages/mox.py\", line 506, in _Verify
raise ExpectedMethodCallsError(self._expected_calls_queue)
ExpectedMethodCallsError: Verify: Expected methods never called:
0. V
1. e
2. r
3. i
4. f
5. y
6. :
7.
8. E
9. x
10. p
11. e
12. c
13. t
14. e
15. d
16.
17. m
18. e
以此类推,持续1346行!
编辑:
它不会让我在8个小时内回答自己的问题,因此我正在编辑找到的解决方案:
正如亚伦·迪古拉(Aaron Digulla)指出的那样,问题不在于鼻子,而在于Mox(我用来模拟对象)。
将此行添加到mox.py的ExpectedMethodCallsError的str方法的顶部可解决此问题(或者仍然是此症状):
if isinstance(self._expected_methods, str):
self._expected_methods = self._expected_methods.split(\"\\n\")
没有找到相关结果
已邀请:
4 个回复
绵扇寸访
荆怖赡
的
或
方法似乎有错误。 或在which6ѭ中注册所需方法的代码中。
惜堡沁戚
如果由于某种原因,变量
是一个字符串,则将迭代该字符串而不是行(与您的情况相同,每字符打印一行)。 出了什么问题:我不知道:)
弓萍功