summaryrefslogtreecommitdiffstats
path: root/test/units/compat/mock.py
blob: 031546093ebced2098bd820c93fd9f780f82d964 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
"""
Compatibility shim for mock imports in modules and module_utils.
This can be removed once support for Python 2.7 is dropped.
"""
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type

try:
    from unittest.mock import (  # pylint: disable=unused-import
        call,
        patch,
        mock_open,
        MagicMock,
        Mock,
    )
except ImportError:
    from mock import (
        call,
        patch,
        mock_open,
        MagicMock,
        Mock,
    )