python unittest assertRaises throws exception when assertRaises fails
<p>I've got code where assertRaises throws an exception when assertRaises fails.  I thought that if assertRaises fails then the test would fail and I'd get a report at the end that says the test failed.  I wasn't expecting the exception to be thrown.  Below is my code.  I'm I doing something wrong?  I'm using Python 2.6.2.</p>

<pre><code>import unittest

class myClass:

    def getName(self):

        raise myExcOne, "my exception one"
        #raise myExcTwo, "my exception two"
        #return "a"

class myExcOne(Exception):
    "exception one"

class myExcTwo(Exception):
    "exception two"


class test_myClass(unittest.TestCase):

    def setUp(self):

        self.myClass = myClass()

    def testgetNameEmpty(self):
        #self.assertRaises(myExcOne,self.myClass.getName)
        #self.assertRaises(myExcTwo,self.myClass.getName)

        try:
            self.assertRaises(myExcTwo,self.myClass.getName)
        except Exception as e:
            pass

if __name__ == "__main__":

    #unittest.main()

    suite = unittest.TestLoader().loadTestsFromTestCase(test_myClass)
    unittest.TextTestRunner(verbosity=2).run(suite)
</code></pre>
