How can I make python's unittest module show output for every assertion, rather than failing at the first one per test case? It would be much easier to debug if I could see the complete pattern of failures rather than just the first one.
In my case the assertions are based on a couple loops over an array containing an object plus some function names and the expected output (see below), so there isn't an obvious way (at least to me) to just separate every assertion into a separate TestCase:
import unittest
import get_nodes
class mytest2(unittest.TestCase):
def testfoo(self):
root = get_nodes.mmnode_plus.factory('mytree.xml')
tests = [
(root, {'skip_traversal': False, 'skip_as_child': True, 'skip_as_parent': False, 'is_leaf': False}),
(root[0], {'skip_traversal': False, 'skip_as_child': False, 'skip_as_parent': False, 'is_leaf': False}),
(root[1], {'skip_traversal': True, 'skip_as_child': True, 'skip_as_parent': True}),
(root[1][0], {'skip_traversal': True}),
(root[0][0], {'is_leaf': False, 'skip_traversal': False, 'skip_as_child': False, 'skip_as_parent': False}),
(root[0][0][0], {'is_leaf': True, 'skip_traversal': False, 'skip_as_child': False, 'skip_as_parent': True}),
(root[0][4], {'skip_traversal': True, 'skip_as_child': True, 'skip_as_parent': True}),
(root[0][7], {'skip_traversal': False, 'skip_as_child': False, 'skip_as_parent': True}),
]
for (node, states) in tests:
for test_state, exp_result in states.iteritems():
self.assertEqual(node.__getattribute__(test_state)(), exp_result, "unexpected %s for state %s of node %s %s" % (not exp_result, test_state, repr(node), repr(node.__dict__)))
unittest.main()
obj.getattribute('hello') returns obj.hello so node.__getattribute__(test_state)() is my way of calling the member function of node whose name is stored in the test_state variable.