title: Customize AssertionError in Python
body: <p>I'm trying to add some text for all assertion errors in my code.</p>
  
  <p>This is my code:</p>
  
  <pre><code>class AssertionError(Exception):
      def __init__(self, msg):
          Exception.__init__(self, msg)
          self.message = msg + "+ SOME TEXT"
  
  assert 1 == 2, "FAIL"
  </code></pre>
  
  <p>Result is </p>
  
  <pre><code>__main__.AssertionError: FAIL
  </code></pre>
  
  <p>I expected to see result: "FAIL + SOME TEXT"</p>
  
  <hr>
  
  <p>Problem is with unittest also.
  I want add some text for all failed tests (Without updating all text message).</p>
  
  <pre><code>import unittest
  
  class TestCase(unittest.TestCase):
      def test1(self):
          self.assertTrue(False, "FAIL!")
  
      def test2(self):
          self.assertLessEqual(10, 2, "FAIL!")
  
  if __name__ == "__main__":
      unittest.main()
  </code></pre>