mock.py 926 B

1234567891011121314151617181920212223242526272829303132
  1. # testing/mock.py
  2. # Copyright (C) 2005-2022 the SQLAlchemy authors and contributors
  3. # <see AUTHORS file>
  4. #
  5. # This module is part of SQLAlchemy and is released under
  6. # the MIT License: https://www.opensource.org/licenses/mit-license.php
  7. """Import stub for mock library.
  8. """
  9. from __future__ import absolute_import
  10. from ..util import py3k
  11. if py3k:
  12. from unittest.mock import MagicMock
  13. from unittest.mock import Mock
  14. from unittest.mock import call
  15. from unittest.mock import patch
  16. from unittest.mock import ANY
  17. else:
  18. try:
  19. from mock import MagicMock # noqa
  20. from mock import Mock # noqa
  21. from mock import call # noqa
  22. from mock import patch # noqa
  23. from mock import ANY # noqa
  24. except ImportError:
  25. raise ImportError(
  26. "SQLAlchemy's test suite requires the "
  27. "'mock' library as of 0.8.2."
  28. )