Use unittest.mock instead of third party mock

Now that we no longer support py27, we can use the standard library
unittest.mock module instead of the third party mock lib.

Change-Id: I89425273ad2092f5394f20c7cdecde14877b1a01
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
This commit is contained in:
Sean McGinnis 2020-04-18 12:01:49 -05:00 committed by Hongbin Lu
parent 9f3ebb2130
commit e5f601a350
65 changed files with 89 additions and 80 deletions

View File

@ -6,7 +6,6 @@
bandit>=1.1.0 # Apache-2.0
doc8>=0.6.0 # Apache-2.0
coverage!=4.4,>=4.0 # Apache-2.0
mock>=2.0.0 # BSD
fixtures>=3.0.0 # Apache-2.0/BSD
hacking>=3.0,<3.1.0 # Apache-2.0
oslotest>=3.2.0 # Apache-2.0

View File

@ -15,9 +15,9 @@
import copy
import os
from unittest import mock
import fixtures
import mock
from oslo_config import cfg
from oslo_log import log
from oslotest import base

View File

@ -35,10 +35,11 @@ For postgres on Ubuntu this can be done with the following commands:
"""
import contextlib
import fixtures
import os
from unittest import mock
from alembic import script
import mock
import fixtures
from oslo_db import exception as db_exc
from oslo_db.sqlalchemy import enginefacade
from oslo_db.sqlalchemy import test_base
@ -49,7 +50,6 @@ import sqlalchemy.exc
from zun.db.sqlalchemy import migration
from zun.tests import base
import os
LOG = logging.getLogger(__name__)

View File

@ -14,7 +14,7 @@
# ceilometer/tests/api/__init__.py). This should be oslo'ified:
# https://bugs.launchpad.net/ironic/+bug/1255115.
import mock
from unittest import mock
# NOTE(deva): import auth_token so we can override a config option
from keystonemiddleware import auth_token # noqa

View File

@ -11,7 +11,8 @@
# limitations under the License.
import collections
import mock
from unittest import mock
import six
from webob import exc

View File

@ -10,8 +10,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import mock
from mock import patch
from unittest import mock
from unittest.mock import patch
from zun import objects
from zun.tests.unit.api import base as api_base

View File

@ -10,8 +10,9 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from mock import patch
from unittest import mock
from unittest.mock import patch
from oslo_utils import uuidutils
from webtest.app import AppError

View File

@ -10,13 +10,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import mock
from mock import patch
from webtest.app import AppError
from unittest import mock
from unittest.mock import patch
from neutronclient.common import exceptions as n_exc
from oslo_utils import uuidutils
import six
from webtest.app import AppError
from zun.common import exception
from zun import objects

View File

@ -10,8 +10,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import mock
from mock import patch
from unittest import mock
from unittest.mock import patch
from oslo_utils import uuidutils

View File

@ -10,11 +10,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import mock
from mock import patch
from webtest.app import AppError
from unittest import mock
from unittest.mock import patch
from oslo_utils import uuidutils
from webtest.app import AppError
from zun.common import exception
import zun.conf

View File

@ -10,7 +10,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from mock import patch
from unittest.mock import patch
from zun.tests.unit.api import base as api_base
from zun.tests.unit.db import utils

View File

@ -10,7 +10,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import mock
from unittest import mock
from zun.tests.unit.api import base as api_base

View File

@ -10,7 +10,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import mock
from unittest import mock
from zun.tests.unit.api import base as api_base

View File

@ -10,11 +10,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import mock
from mock import patch
from webtest.app import AppError
from unittest import mock
from unittest.mock import patch
from oslo_utils import uuidutils
from webtest.app import AppError
from zun import objects
from zun.tests.unit.api import base as api_base

View File

@ -10,7 +10,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import mock
from unittest import mock
from oslo_config import cfg
from zun.api import servicegroup

View File

@ -12,7 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from oslo_upgradecheck.upgradecheck import Code

View File

@ -10,7 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from cinderclient import client as cinderclient
from glanceclient import client as glanceclient

View File

@ -10,7 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from zun.common import exception
from zun.common import mount

View File

@ -14,7 +14,7 @@
# under the License.
import inspect
import mock
from unittest import mock
from oslo_utils import importutils
from osprofiler import initializer as profiler_init

View File

@ -13,7 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from oslo_serialization import jsonutils as json
from zun.common import context

View File

@ -12,7 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from zun.common import exception
from zun.common import utils

View File

@ -12,7 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from zun.common import consts
from zun.common import exception

View File

@ -12,7 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from oslo_utils import uuidutils
from six import StringIO

View File

@ -12,7 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from zun.compute import claims
from zun.compute import compute_node_tracker

View File

@ -12,7 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from zun.common import exception
from zun.compute import rpcapi

View File

@ -11,7 +11,8 @@
# under the License.
import collections
import mock
from unittest import mock
from oslo_config import cfg
import six

View File

@ -11,9 +11,9 @@
# under the License.
from collections import defaultdict
from docker import errors
import mock
from unittest import mock
from docker import errors
from oslo_utils import units
from oslo_utils import uuidutils

View File

@ -10,7 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from oslo_serialization import jsonutils

View File

@ -12,11 +12,11 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
import six
from unittest import mock
from unittest.mock import mock_open
from mock import mock_open
from oslo_serialization import jsonutils
import six
from zun.common import exception
from zun.container.os_capability.linux import os_capability_linux

View File

@ -12,7 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from docker import errors

View File

@ -12,10 +12,10 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
import os
import shutil
import tempfile
from unittest import mock
from zun.common import exception
import zun.conf

View File

@ -13,7 +13,7 @@
Tests For kuryr network
"""
import copy
import mock
from unittest import mock
from neutronclient.common import exceptions as n_exc

View File

@ -12,7 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from testtools.matchers import HasLength

View File

@ -10,7 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from testtools.matchers import HasLength

View File

@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from oslo_utils import uuidutils
from testtools.matchers import HasLength

View File

@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from oslo_utils import fixture as utils_fixture
from oslo_utils import timeutils

View File

@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from testtools.matchers import HasLength

View File

@ -13,7 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from testtools.matchers import HasLength
from zun import objects

View File

@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from testtools.matchers import HasLength

View File

@ -12,8 +12,8 @@
import datetime
import gettext
from unittest import mock
import mock
from oslo_versionedobjects import exception as object_exception
from oslo_versionedobjects import fields
from oslo_versionedobjects import fixture

View File

@ -10,7 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from zun import objects
from zun.tests.unit.db import base

View File

@ -10,7 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from zun.common import consts
from zun import objects

View File

@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from testtools.matchers import HasLength

View File

@ -10,7 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from testtools.matchers import HasLength

View File

@ -10,7 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from oslo_utils import uuidutils
from testtools.matchers import HasLength

View File

@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from oslo_utils import uuidutils
from testtools.matchers import HasLength

View File

@ -10,7 +10,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from testtools.matchers import HasLength
from zun import objects

View File

@ -14,8 +14,8 @@
# under the License.
import functools
from unittest import mock
import mock
from zun.pci import whitelist

View File

@ -12,7 +12,8 @@
# under the License.
import mock
from unittest import mock
import six
from zun.common import exception

View File

@ -14,8 +14,7 @@
# under the License.
import copy
import mock
from unittest import mock
import zun
from zun.common import context

View File

@ -13,7 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from oslo_config import cfg
from zun.common import exception

View File

@ -16,9 +16,9 @@
import glob
import os
from unittest import mock
import fixtures
import mock
from six.moves import builtins
from zun.common import exception

View File

@ -11,7 +11,7 @@
# under the License.
import collections
import mock
from unittest import mock
from oslo_config import cfg

View File

@ -11,10 +11,10 @@
# under the License.
import copy
import time
from unittest import mock
import fixtures
from keystoneauth1 import exceptions as ks_exc
import mock
import os_resource_classes as orc
from oslo_serialization import jsonutils
from oslo_utils.fixture import uuidsentinel as uuids

View File

@ -10,7 +10,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from oslo_utils import timeutils
from zun.common import context

View File

@ -10,7 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from zun import objects
from zun.pci import stats

View File

@ -13,8 +13,8 @@
Tests for base filter
"""
import inspect
from unittest import mock
import mock
from zun.scheduler import base_filters
from zun.tests import base

View File

@ -10,7 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from zun.common import exception
from zun import objects

View File

@ -10,7 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from oslo_utils import timeutils

View File

@ -13,7 +13,7 @@
Tests For Scheduler
"""
import mock
from unittest import mock
from zun import objects
from zun.tests import base

View File

@ -10,7 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
import zun.conf
from zun import objects

View File

@ -13,8 +13,8 @@
# under the License.
import textwrap
from unittest import mock
import mock
import pycodestyle
from zun.hacking import checks

View File

@ -10,7 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from cinderclient import exceptions as cinder_exception
from oslo_utils import timeutils

View File

@ -10,7 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from cinderclient import exceptions as cinder_exception
from os_brick import exception as os_brick_exception

View File

@ -10,7 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from oslo_serialization import jsonutils
from oslo_utils import uuidutils