我正在用 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 .
关于python - Python Nose 测试会显示错误的值吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43942992/