Как правило, вы хотите унаследовать от юнит-класса django TestCase, который вы можете получить, импортируя из django.test. Тем не менее, вы можете передать аргумент msg тому, что вы пытаетесь оценить, содержащему сообщение об ошибке.
Вот пример из Humanize:
class HumanizeTests(TestCase):
def humanize_tester(self, test_list, result_list, method):
# Using max below ensures we go through both lists
# However, if the lists are not equal length, this raises an exception
for test_content, result in zip(test_list, result_list):
t = Template('{%% load humanize %%}{{ test_content|%s }}' % method)
rendered = t.render(Context(locals())).strip()
self.assertEqual(rendered, escape(result),
msg="%s test failed, produced '%s', should've produced '%s'" % (method, rendered, result))
Очевидно, что вам не нужно выглядеть так, как указано выше, но вы можете увидеть аргумент msg в действии.