Debian Codegraph @

ansible_collections/community/hashi_vault/tests/unit/compat/mock.py

raw
1 # Copyright (c) 2014, Toshio Kuratomi <[email protected]>
2 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
3 # SPDX-License-Identifier: GPL-3.0-or-later
4
5 # Make coding more python3-ish
6 from __future__ import (absolute_import, division, print_function)
7 __metaclass__ = type
8
9 '''
10 Compat module for Python3.x's unittest.mock module
11 '''
12 # Python 2.7
13
14 # Note: Could use the pypi mock library on python3.x as well as python2.x. It
15 # is the same as the python3 stdlib mock library
16
17 try:
18 # Allow wildcard import because we really do want to import all of mock's
19 # symbols into this compat shim
20 # pylint: disable=wildcard-import,unused-wildcard-import
21 from unittest.mock import *
22 except ImportError:
23 # Python 2
24 # pylint: disable=wildcard-import,unused-wildcard-import
25 try:
26 from mock import *
27 except ImportError:
28 print('You need the mock library installed on python2.x to run tests')