Checking error message in test in python2.7 and 3.4
<p>I need to write a test using unittest that checks the content of an error message. This test needs to work for both python2.7 and python3.4. Originally, I had the test looking something like this:</p>

<pre><code>class MyFuncTestCaes(TestCase)
    def test_my_func(self):
        with self.assertRaises(TypeError) as context:
            my_func()
        self.assertIn("some message", context.exception.message
</code></pre>

<p>This works for Python2.7, but not for Python3.4 - there no longer seems to be a <code>message</code> attribute on <code>exception</code>. How can I modify this test so that it works for both versions of Python?</p>