From 9a59610643805f121279519045ff29640fade749 Mon Sep 17 00:00:00 2001 From: Sean McGinnis Date: Sat, 18 Apr 2020 11:54:10 -0500 Subject: [PATCH] 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: Ia6927351f591be0c57fd73515b2542a0af35f82b Signed-off-by: Sean McGinnis --- masakari/test.py | 2 +- masakari/tests/unit/api/openstack/ha/test_extension_info.py | 2 +- masakari/tests/unit/api/openstack/ha/test_hosts.py | 3 ++- masakari/tests/unit/api/openstack/ha/test_notifications.py | 2 +- masakari/tests/unit/api/openstack/ha/test_segments.py | 3 ++- masakari/tests/unit/api/openstack/ha/test_versions.py | 2 +- masakari/tests/unit/api/openstack/test_common.py | 3 ++- masakari/tests/unit/api/openstack/test_extensions.py | 3 ++- masakari/tests/unit/api/openstack/test_wsgi.py | 2 +- masakari/tests/unit/api/test_utils.py | 2 +- masakari/tests/unit/cmd/test_masakari_api.py | 2 +- masakari/tests/unit/compute/test_nova.py | 3 ++- .../unit/engine/drivers/taskflow/test_host_failure_flow.py | 2 +- .../unit/engine/drivers/taskflow/test_instance_failure_flow.py | 2 +- .../unit/engine/drivers/taskflow/test_process_failure_flow.py | 2 +- .../tests/unit/engine/drivers/taskflow/test_taskflow_driver.py | 3 ++- masakari/tests/unit/engine/test_engine_mgr.py | 3 ++- masakari/tests/unit/engine/test_rpcapi.py | 2 +- masakari/tests/unit/engine/test_utils.py | 2 +- masakari/tests/unit/ha/test_api.py | 3 ++- masakari/tests/unit/notifications/objects/test_notification.py | 2 +- masakari/tests/unit/objects/test_hosts.py | 2 +- masakari/tests/unit/objects/test_notifications.py | 2 +- masakari/tests/unit/objects/test_objects.py | 2 +- masakari/tests/unit/objects/test_segments.py | 2 +- masakari/tests/unit/test_hacking.py | 2 +- masakari/tests/unit/test_masakari_manage.py | 2 +- masakari/tests/unit/test_rpc.py | 2 +- masakari/tests/unit/test_service.py | 3 ++- masakari/tests/unit/test_utils.py | 2 +- masakari/tests/unit/test_wsgi.py | 2 +- 31 files changed, 40 insertions(+), 31 deletions(-) diff --git a/masakari/test.py b/masakari/test.py index 57d576bd..bc970795 100644 --- a/masakari/test.py +++ b/masakari/test.py @@ -23,9 +23,9 @@ import contextlib import datetime import eventlet eventlet.monkey_patch(os=False) # noqa +from unittest import mock import fixtures -import mock import six import testtools diff --git a/masakari/tests/unit/api/openstack/ha/test_extension_info.py b/masakari/tests/unit/api/openstack/ha/test_extension_info.py index 6bd00488..8fecae44 100644 --- a/masakari/tests/unit/api/openstack/ha/test_extension_info.py +++ b/masakari/tests/unit/api/openstack/ha/test_extension_info.py @@ -11,7 +11,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from masakari.api.openstack.ha import extension_info from masakari import policy diff --git a/masakari/tests/unit/api/openstack/ha/test_hosts.py b/masakari/tests/unit/api/openstack/ha/test_hosts.py index eb0553e1..78f0d33e 100644 --- a/masakari/tests/unit/api/openstack/ha/test_hosts.py +++ b/masakari/tests/unit/api/openstack/ha/test_hosts.py @@ -15,8 +15,9 @@ """Tests for the hosts api.""" +from unittest import mock + import ddt -import mock from oslo_serialization import jsonutils from six.moves import http_client as http from webob import exc diff --git a/masakari/tests/unit/api/openstack/ha/test_notifications.py b/masakari/tests/unit/api/openstack/ha/test_notifications.py index 49101f2d..47e33d6f 100644 --- a/masakari/tests/unit/api/openstack/ha/test_notifications.py +++ b/masakari/tests/unit/api/openstack/ha/test_notifications.py @@ -16,9 +16,9 @@ """Tests for the notifications api.""" import copy +from unittest import mock import ddt -import mock from oslo_serialization import jsonutils from oslo_utils import timeutils from six.moves import http_client as http diff --git a/masakari/tests/unit/api/openstack/ha/test_segments.py b/masakari/tests/unit/api/openstack/ha/test_segments.py index 6af8acf7..33b5f6b3 100644 --- a/masakari/tests/unit/api/openstack/ha/test_segments.py +++ b/masakari/tests/unit/api/openstack/ha/test_segments.py @@ -15,8 +15,9 @@ """Tests for the failover segment api.""" +from unittest import mock + import ddt -import mock from oslo_serialization import jsonutils from six.moves import http_client as http from webob import exc diff --git a/masakari/tests/unit/api/openstack/ha/test_versions.py b/masakari/tests/unit/api/openstack/ha/test_versions.py index 62140b39..b587243b 100644 --- a/masakari/tests/unit/api/openstack/ha/test_versions.py +++ b/masakari/tests/unit/api/openstack/ha/test_versions.py @@ -14,8 +14,8 @@ # under the License. import copy +from unittest import mock -import mock from oslo_serialization import jsonutils from six.moves import http_client as http import webob diff --git a/masakari/tests/unit/api/openstack/test_common.py b/masakari/tests/unit/api/openstack/test_common.py index fba33068..570eaebd 100644 --- a/masakari/tests/unit/api/openstack/test_common.py +++ b/masakari/tests/unit/api/openstack/test_common.py @@ -17,8 +17,9 @@ Test suites for 'common' code used throughout the OpenStack HTTP API. """ -import mock from testtools import matchers +from unittest import mock + import webob from masakari.api.openstack import common diff --git a/masakari/tests/unit/api/openstack/test_extensions.py b/masakari/tests/unit/api/openstack/test_extensions.py index e2d810d3..e02b1264 100644 --- a/masakari/tests/unit/api/openstack/test_extensions.py +++ b/masakari/tests/unit/api/openstack/test_extensions.py @@ -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 six.moves import http_client as http import webob.exc diff --git a/masakari/tests/unit/api/openstack/test_wsgi.py b/masakari/tests/unit/api/openstack/test_wsgi.py index 585949aa..c3e866ce 100644 --- a/masakari/tests/unit/api/openstack/test_wsgi.py +++ b/masakari/tests/unit/api/openstack/test_wsgi.py @@ -14,8 +14,8 @@ # under the License. import inspect +from unittest import mock -import mock import six from six.moves import http_client as http import testscenarios diff --git a/masakari/tests/unit/api/test_utils.py b/masakari/tests/unit/api/test_utils.py index 5d0df79b..0a73916d 100644 --- a/masakari/tests/unit/api/test_utils.py +++ b/masakari/tests/unit/api/test_utils.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import mock import socket import testtools +from unittest import mock from masakari.api import utils as api_utils from masakari.notifications.objects import base as notification_base diff --git a/masakari/tests/unit/cmd/test_masakari_api.py b/masakari/tests/unit/cmd/test_masakari_api.py index 6f573d20..9844ccc2 100644 --- a/masakari/tests/unit/cmd/test_masakari_api.py +++ b/masakari/tests/unit/cmd/test_masakari_api.py @@ -11,7 +11,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from masakari.cmd import api from masakari import config diff --git a/masakari/tests/unit/compute/test_nova.py b/masakari/tests/unit/compute/test_nova.py index fdd315f1..6675f3ab 100644 --- a/masakari/tests/unit/compute/test_nova.py +++ b/masakari/tests/unit/compute/test_nova.py @@ -12,7 +12,8 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock + from six.moves import http_client as http from keystoneauth1 import exceptions as keystone_exception diff --git a/masakari/tests/unit/engine/drivers/taskflow/test_host_failure_flow.py b/masakari/tests/unit/engine/drivers/taskflow/test_host_failure_flow.py index 6b769de4..d57807ff 100644 --- a/masakari/tests/unit/engine/drivers/taskflow/test_host_failure_flow.py +++ b/masakari/tests/unit/engine/drivers/taskflow/test_host_failure_flow.py @@ -17,9 +17,9 @@ Unit Tests for host failure TaskFlow """ import copy +from unittest import mock import ddt -import mock from masakari.compute import nova from masakari import conf diff --git a/masakari/tests/unit/engine/drivers/taskflow/test_instance_failure_flow.py b/masakari/tests/unit/engine/drivers/taskflow/test_instance_failure_flow.py index e64994e6..5ae18618 100644 --- a/masakari/tests/unit/engine/drivers/taskflow/test_instance_failure_flow.py +++ b/masakari/tests/unit/engine/drivers/taskflow/test_instance_failure_flow.py @@ -17,7 +17,7 @@ Unit Tests for instance failure TaskFlow """ -import mock +from unittest import mock from masakari.compute import nova from masakari import context diff --git a/masakari/tests/unit/engine/drivers/taskflow/test_process_failure_flow.py b/masakari/tests/unit/engine/drivers/taskflow/test_process_failure_flow.py index 7c8774b4..f9273a4a 100644 --- a/masakari/tests/unit/engine/drivers/taskflow/test_process_failure_flow.py +++ b/masakari/tests/unit/engine/drivers/taskflow/test_process_failure_flow.py @@ -17,7 +17,7 @@ Unit Tests for process failure TaskFlow """ -import mock +from unittest import mock from masakari.compute import nova from masakari import context diff --git a/masakari/tests/unit/engine/drivers/taskflow/test_taskflow_driver.py b/masakari/tests/unit/engine/drivers/taskflow/test_taskflow_driver.py index ac4d8e4e..c9439a62 100644 --- a/masakari/tests/unit/engine/drivers/taskflow/test_taskflow_driver.py +++ b/masakari/tests/unit/engine/drivers/taskflow/test_taskflow_driver.py @@ -13,7 +13,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 taskflow.persistence import models from taskflow.persistence import path_based diff --git a/masakari/tests/unit/engine/test_engine_mgr.py b/masakari/tests/unit/engine/test_engine_mgr.py index 7aad8c56..adee6649 100644 --- a/masakari/tests/unit/engine/test_engine_mgr.py +++ b/masakari/tests/unit/engine/test_engine_mgr.py @@ -12,7 +12,8 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock + from oslo_utils import importutils from oslo_utils import timeutils diff --git a/masakari/tests/unit/engine/test_rpcapi.py b/masakari/tests/unit/engine/test_rpcapi.py index e2520ce0..91eac71a 100644 --- a/masakari/tests/unit/engine/test_rpcapi.py +++ b/masakari/tests/unit/engine/test_rpcapi.py @@ -17,8 +17,8 @@ Unit Tests for masakari.engine.rpcapi """ import copy +from unittest import mock -import mock from masakari import context from masakari.engine import rpcapi as engine_rpcapi diff --git a/masakari/tests/unit/engine/test_utils.py b/masakari/tests/unit/engine/test_utils.py index 8ce54c48..df64383b 100644 --- a/masakari/tests/unit/engine/test_utils.py +++ b/masakari/tests/unit/engine/test_utils.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import mock import socket import testtools +from unittest import mock from masakari.engine import utils as engine_utils from masakari.notifications.objects import base as notification_base diff --git a/masakari/tests/unit/ha/test_api.py b/masakari/tests/unit/ha/test_api.py index 2106f554..af465ac6 100644 --- a/masakari/tests/unit/ha/test_api.py +++ b/masakari/tests/unit/ha/test_api.py @@ -16,7 +16,8 @@ """Tests for the failover segment api.""" import copy -import mock +from unittest import mock + from oslo_utils import timeutils from masakari.api import utils as api_utils diff --git a/masakari/tests/unit/notifications/objects/test_notification.py b/masakari/tests/unit/notifications/objects/test_notification.py index e8f9f1eb..df22f76c 100644 --- a/masakari/tests/unit/notifications/objects/test_notification.py +++ b/masakari/tests/unit/notifications/objects/test_notification.py @@ -14,8 +14,8 @@ # limitations under the License. import collections +from unittest import mock -import mock from oslo_utils import timeutils from oslo_versionedobjects import fixture diff --git a/masakari/tests/unit/objects/test_hosts.py b/masakari/tests/unit/objects/test_hosts.py index 29efd9a0..01a6ac9a 100644 --- a/masakari/tests/unit/objects/test_hosts.py +++ b/masakari/tests/unit/objects/test_hosts.py @@ -14,8 +14,8 @@ # under the License. import copy +from unittest import mock -import mock from oslo_utils import timeutils from masakari.api import utils as api_utils diff --git a/masakari/tests/unit/objects/test_notifications.py b/masakari/tests/unit/objects/test_notifications.py index bb7375ca..810bb264 100644 --- a/masakari/tests/unit/objects/test_notifications.py +++ b/masakari/tests/unit/objects/test_notifications.py @@ -14,8 +14,8 @@ # under the License. import copy +from unittest import mock -import mock from oslo_utils import timeutils from oslo_utils import uuidutils diff --git a/masakari/tests/unit/objects/test_objects.py b/masakari/tests/unit/objects/test_objects.py index 7cb0c023..4f8cb0e1 100644 --- a/masakari/tests/unit/objects/test_objects.py +++ b/masakari/tests/unit/objects/test_objects.py @@ -18,8 +18,8 @@ import datetime import inspect import os import pprint +from unittest import mock -import mock from oslo_versionedobjects import exception as ovo_exc from oslo_versionedobjects import fixture diff --git a/masakari/tests/unit/objects/test_segments.py b/masakari/tests/unit/objects/test_segments.py index 2a911add..854e79cf 100644 --- a/masakari/tests/unit/objects/test_segments.py +++ b/masakari/tests/unit/objects/test_segments.py @@ -14,8 +14,8 @@ # under the License. import copy +from unittest import mock -import mock from oslo_utils import timeutils from masakari.api import utils as api_utils diff --git a/masakari/tests/unit/test_hacking.py b/masakari/tests/unit/test_hacking.py index f0536f85..3d698d62 100644 --- a/masakari/tests/unit/test_hacking.py +++ b/masakari/tests/unit/test_hacking.py @@ -13,9 +13,9 @@ # under the License. import textwrap +from unittest import mock import ddt -import mock import pep8 from masakari.hacking import checks diff --git a/masakari/tests/unit/test_masakari_manage.py b/masakari/tests/unit/test_masakari_manage.py index eebcf4fc..ef13c180 100644 --- a/masakari/tests/unit/test_masakari_manage.py +++ b/masakari/tests/unit/test_masakari_manage.py @@ -12,8 +12,8 @@ # License for the specific language governing permissions and limitations # under the License. -import mock import sys +from unittest import mock from masakari.cmd import manage from masakari import context diff --git a/masakari/tests/unit/test_rpc.py b/masakari/tests/unit/test_rpc.py index 22266c61..3ce35460 100644 --- a/masakari/tests/unit/test_rpc.py +++ b/masakari/tests/unit/test_rpc.py @@ -13,9 +13,9 @@ # under the License. import copy +from unittest import mock import fixtures -import mock import oslo_messaging as messaging from oslo_messaging.rpc import dispatcher from oslo_serialization import jsonutils diff --git a/masakari/tests/unit/test_service.py b/masakari/tests/unit/test_service.py index a7c9d52c..e4c685bb 100644 --- a/masakari/tests/unit/test_service.py +++ b/masakari/tests/unit/test_service.py @@ -17,7 +17,8 @@ Unit Tests for remote procedure calls using queue """ -import mock +from unittest import mock + from oslo_concurrency import processutils from oslo_config import cfg from oslo_service import service as _service diff --git a/masakari/tests/unit/test_utils.py b/masakari/tests/unit/test_utils.py index 3c65bee3..bbd49517 100644 --- a/masakari/tests/unit/test_utils.py +++ b/masakari/tests/unit/test_utils.py @@ -13,9 +13,9 @@ # under the License. import importlib +from unittest import mock import eventlet -import mock from oslo_config import cfg from oslo_context import context as common_context from oslo_context import fixture as context_fixture diff --git a/masakari/tests/unit/test_wsgi.py b/masakari/tests/unit/test_wsgi.py index bfe9bfeb..c2527cd2 100644 --- a/masakari/tests/unit/test_wsgi.py +++ b/masakari/tests/unit/test_wsgi.py @@ -19,10 +19,10 @@ import os.path import socket import tempfile +from unittest import mock import eventlet import eventlet.wsgi -import mock from oslo_config import cfg import requests import testtools