test_utils.py 637 B

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