title: Outputting data from unit test in Python
body: <p>If I'm writing unit tests in Python (using the unittest module), is it possible to output data from a failed test, so I can examine it to help deduce what caused the error?</p>
  <p>I am aware of the ability to create a customized message, which can carry some information, but sometimes you might deal with more complex data, that can't easily be represented as a string.</p>
  <p>For example, suppose you had a class Foo, and were testing a method bar, using data from a list called testdata:</p>
  <pre><code>class TestBar(unittest.TestCase):
      def runTest(self):
          for t1, t2 in testdata:
              f = Foo(t1)
              self.assertEqual(f.bar(t2), 2)
  </code></pre>
  <p>If the test failed, I might want to output t1, t2 and/or f, to see why this particular data resulted in a failure. By output, I mean that the variables can be accessed like any other variables, after the test has been run.</p>