Python 鼻子测试会显示错误的值吗?

Can Python nose tests show wrong value?

我正在 运行 一些 nose 测试,它工作正常,但在结果中,我只看到哪条线的哪个测试失败了,而不是错误的值是什么。例如,我是 运行 nosetests -v 我得到这个:

======================================================================
FAIL: tests.test_convert_to_steer
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/home/pi/ared/tests.py", line 7, in test_convert_to_steer
    assert convert_to_steer(100, 100) == 100
AssertionError

这只告诉我哪些测试失败了,但我现在必须手动打印出 convert_to_steer(100, 100) 的结果以查看结果是什么。

有谁知道它还可以告诉我错误的结果是什么?

如果您的测试套件扩展 unittest.TestCase,您可以使用 self.assertEqual(convert_to_steer(100, 100), 100)

有关详细信息,请参阅 the docs