我正在使用unittest.TestCase为我的 django 应用程序编写测试用例(这与 python 中的 unittest.TestCase 基本相同)。每当测试方法失败时,我都会以下面的格式得到它的解释。有没有办法可以将自定义/调试消息添加到失败的测试方法的输出中?
======================================================================
FAIL: test_bad_votes (polls.tests.views.PollsViewsTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/colinh/Development/tutorials/guide-to-testing-in-django/polls/tests/views.py", line 66, in test_bad_votes
self.assertEqual(resp.context['form']['choice'].errors, [u'This field is required.'])
AssertionError: [] != [u'This field is required.']