title: Is there a way to catch unittest exceptions with PyCharm?
body: <p>The python unittest runner handles all exceptions. I would like to catch them with my debugger.</p>
  
  <p>Is there a way to make my unittest runner re-raise tests exceptions to terminate the process?
  I want to handle them myself.</p>
  
  <p><strong>Edit</strong>: Found a solution.</p>
  
  <p>You can create a unittest.TestSuite and call <a href="http://docs.python.org/2/library/unittest.html#unittest.TestSuite.debug">debug()</a> to run the tests you want to debug - including catching the exceptions with your debugger!</p>
  
  <p>It can be easily done with this pattern:</p>
  
  <pre><code>import unittest
  
  class DebuggableTestCase(unittest.TestCase):
      @classmethod
      def debugTestCase(cls):
          loader = unittest.defaultTestLoader
          testSuite = loader.loadTestsFromTestCase(cls)
          testSuite.debug()
  
  class MyTestCase(DebuggableTestCase):
      def test_function_that_fails(self):
          raise Exception('test')
  
  if __name__ == '__main__':
      MyTestCase.debugTestCase()
  </code></pre>