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 bandit>=1.1.0 # Apache-2.0
doc8>=0.6.0 # Apache-2.0 doc8>=0.6.0 # Apache-2.0
coverage!=4.4,>=4.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 fixtures>=3.0.0 # Apache-2.0/BSD
hacking>=3.0,<3.1.0 # Apache-2.0 hacking>=3.0,<3.1.0 # Apache-2.0
oslotest>=3.2.0 # Apache-2.0 oslotest>=3.2.0 # Apache-2.0

View File

@ -15,9 +15,9 @@
import copy import copy
import os import os
from unittest import mock
import fixtures import fixtures
import mock
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log from oslo_log import log
from oslotest import base 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 contextlib
import fixtures import os
from unittest import mock
from alembic import script from alembic import script
import mock import fixtures
from oslo_db import exception as db_exc from oslo_db import exception as db_exc
from oslo_db.sqlalchemy import enginefacade from oslo_db.sqlalchemy import enginefacade
from oslo_db.sqlalchemy import test_base from oslo_db.sqlalchemy import test_base
@ -49,7 +50,6 @@ import sqlalchemy.exc
from zun.db.sqlalchemy import migration from zun.db.sqlalchemy import migration
from zun.tests import base from zun.tests import base
import os
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -10,7 +10,8 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # 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.api import base as api_base
from zun.tests.unit.db import utils from zun.tests.unit.db import utils

View File

@ -10,7 +10,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import mock from unittest import mock
from zun.tests.unit.api import base as api_base 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 # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import mock from unittest import mock
from zun.tests.unit.api import base as api_base 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 # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import mock from unittest import mock
from mock import patch from unittest.mock import patch
from webtest.app import AppError
from oslo_utils import uuidutils from oslo_utils import uuidutils
from webtest.app import AppError
from zun import objects from zun import objects
from zun.tests.unit.api import base as api_base 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 # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import mock from unittest import mock
from oslo_config import cfg from oslo_config import cfg
from zun.api import servicegroup from zun.api import servicegroup

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -12,11 +12,11 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import mock from unittest import mock
import six from unittest.mock import mock_open
from mock import mock_open
from oslo_serialization import jsonutils from oslo_serialization import jsonutils
import six
from zun.common import exception from zun.common import exception
from zun.container.os_capability.linux import os_capability_linux 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 # License for the specific language governing permissions and limitations
# under the License. # under the License.
import mock from unittest import mock
from docker import errors from docker import errors

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -10,7 +10,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import mock from unittest import mock
from cinderclient import exceptions as cinder_exception from cinderclient import exceptions as cinder_exception
from os_brick import exception as os_brick_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 # License for the specific language governing permissions and limitations
# under the License. # under the License.
import mock from unittest import mock
from oslo_serialization import jsonutils from oslo_serialization import jsonutils
from oslo_utils import uuidutils from oslo_utils import uuidutils