gpt4 book ai didi

python - Python Nose 测试会显示错误的值吗?

转载 作者:行者123 更新时间:2023-11-28 22:27:44 25 4
gpt4 key购买 nike

我正在用 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com