title: Using python unittest, how can I assert an error reported gave a certain message?
body: <p>Let's say I have a method that looks like this:</p>
  
  <pre><code>def my_function(arg1, arg2):
      if arg1:
          raise RuntimeError('error message A')
      else:
          raise RuntimeError('error message B')
  </code></pre>
  
  <p>Using python's builtin unittets library, is there any way to tell WHICH <code>RuntimeError</code> was raised? I have been doing:</p>
  
  <pre><code>import unittest
  from myfile import my_function
  
  
  class MyTestCase(unittest.TestCase):
      def test_my_function(self):
          self.assertRaises(RuntimeError, my_function, arg1, arg2)
  </code></pre>
  
  <p>But this only asserts that a <code>RuntimeError</code> was encountered. I want to be able to tell WHICH <code>RuntimeError</code> was encountered. Checking the actual error message is the only way I think this could be accomplished but I can't seem to find any assert method that also tries to assert the error message</p>