我最近开始使用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中expectedMethodCallsRor的str方法的顶部可以修复该问题(或者仍然修复此症状):
if isinstance(self._expected_methods, str):
  self._expected_methods = self._expected_methods.split("\n")

最佳答案

正如Aaron Digulla指出的,问题不在鼻子,而在Mox(我用它来模拟对象)。
将此行添加到mox.py中expectedMethodCallsRor的str方法的顶部可以修复该问题(或者仍然修复此症状):

if isinstance(self._expected_methods, basestring):
  self._expected_methods = self._expected_methods.split("\n")

10-04 13:17