1try: 2 import unittest2 as unittest 3except ImportError: 4 import unittest 5 6# Python 2.7 - 3.1 7if not hasattr(unittest.TestCase, 'assertRaisesRegex'): 8 unittest.TestCase.assertRaisesRegex = unittest.TestCase.assertRaisesRegexp 9