summaryrefslogtreecommitdiffstats
path: root/test/units/compat/mock.py
blob: 58dc78e07406c011bf5ad1dbb82baa226e7f7e06 (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 (
        call,
        patch,
        mock_open,
        MagicMock,
        Mock,
    )
except ImportError:
    from mock import (
        call,
        patch,
        mock_open,
        MagicMock,
        Mock,
    )