1import unittest 2 3try: 4 from typing import Any 5except ImportError: 6 pass # only needed to check type annotations 7 8 9class Py23TestCase(unittest.TestCase): 10 11 def __init__(self, *args, **kwargs): # type: (Any, Any) -> None 12 super(Py23TestCase, self).__init__(*args, **kwargs) 13 try: 14 self.assertRaisesRegex 15 except AttributeError: 16 # assertRaisesRegexp is deprecated in Python3 but assertRaisesRegex doesn't exist in Python2 17 # This fix is used in order to avoid using the alias from the six library 18 self.assertRaisesRegex = self.assertRaisesRegexp # type: ignore 19