From 41a21bc80781571e4ca4a2d881d16587bff9f42c Mon Sep 17 00:00:00 2001 From: Sean McGinnis Date: Sat, 18 Apr 2020 12:00:58 -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: I130c03e12ddc53ce7ced728a43b10b142f7b066f Signed-off-by: Sean McGinnis Co-Authored-By: Hiroo Kitamura --- lower-constraints.txt | 1 - tacker/db/migration/cli.py | 4 ++-- tacker/tests/base.py | 2 +- tacker/tests/unit/agent/linux/test_utils.py | 2 +- tacker/tests/unit/api/test_v2_extension.py | 3 ++- tacker/tests/unit/api/v1/test_resource.py | 3 ++- tacker/tests/unit/api/v1/test_resource_helper.py | 2 +- tacker/tests/unit/api/v1/test_router.py | 2 +- tacker/tests/unit/api/v1/test_vim.py | 3 ++- tacker/tests/unit/api/v2/test_api_v2.py | 2 +- tacker/tests/unit/base.py | 3 ++- tacker/tests/unit/common/test_config.py | 2 +- tacker/tests/unit/common/test_csar_utils.py | 2 +- tacker/tests/unit/common/test_log.py | 2 +- .../tests/unit/conductor/conductorrpc/test_vnf_pkgm_rpc.py | 2 +- tacker/tests/unit/conductor/test_conductor_server.py | 4 ++-- .../db/common_services/test_common_services_db_plugin.py | 2 +- tacker/tests/unit/db/test_db_migration.py | 2 +- tacker/tests/unit/db/test_db_purge_delete.py | 2 +- tacker/tests/unit/extensions/test_common_services.py | 2 +- tacker/tests/unit/glance_store/test_store.py | 2 +- .../tests/unit/nfvo/drivers/vim/test_kubernetes_driver.py | 3 ++- .../tests/unit/nfvo/drivers/vim/test_openstack_driver.py | 2 +- .../drivers/vnffg/sfc_drivers/networking-sfc/test_n_sfc.py | 2 +- tacker/tests/unit/nfvo/test_nfvo_plugin.py | 6 +++--- tacker/tests/unit/objects/test_vnf_deployment_flavour.py | 2 +- tacker/tests/unit/objects/test_vnf_instance.py | 6 +++--- tacker/tests/unit/objects/test_vnf_package.py | 3 ++- tacker/tests/unit/objects/test_vnf_resource.py | 2 +- tacker/tests/unit/test_alarm_receiver.py | 3 ++- tacker/tests/unit/test_context.py | 3 ++- tacker/tests/unit/test_policy.py | 3 ++- tacker/tests/unit/test_wsgi.py | 3 ++- tacker/tests/unit/tests/test_post_mortem_debug.py | 2 +- tacker/tests/unit/vnflcm/test_controller.py | 2 +- tacker/tests/unit/vnflcm/test_vnflcm_driver.py | 3 ++- .../unit/vnfm/infra_drivers/openstack/test_openstack.py | 3 +-- .../vnfm/infra_drivers/openstack/test_openstack_driver.py | 7 ++++--- tacker/tests/unit/vnfm/infra_drivers/openstack/test_vdu.py | 2 +- .../unit/vnfm/monitor_drivers/http_ping/test_http_ping.py | 3 ++- tacker/tests/unit/vnfm/monitor_drivers/ping/test_ping.py | 2 +- .../tests/unit/vnfm/monitor_drivers/zabbix/test_zabbix.py | 2 +- .../vnfm/policy_actions/autoscaling/test_autoscaling.py | 2 +- tacker/tests/unit/vnfm/policy_actions/log/test_log.py | 2 +- .../tests/unit/vnfm/policy_actions/respawn/test_respawn.py | 2 +- .../vnfm/policy_actions/vdu_autoheal/test_vdu_autoheal.py | 2 +- tacker/tests/unit/vnfm/test_k8s_plugin.py | 4 ++-- tacker/tests/unit/vnfm/test_monitor.py | 3 ++- tacker/tests/unit/vnfm/test_plugin.py | 4 ++-- tacker/tests/unit/vnfm/test_vim_client.py | 2 +- tacker/tests/unit/vnfpkgm/test_controller.py | 3 ++- test-requirements.txt | 1 - 52 files changed, 75 insertions(+), 63 deletions(-) diff --git a/lower-constraints.txt b/lower-constraints.txt index 4e1e0c138..e4e784938 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -53,7 +53,6 @@ linecache2==1.0.0 Mako==1.0.7 MarkupSafe==1.0 mccabe==0.2.1 -mock==3.0.0 monotonic==1.4 mox3==0.25.0 msgpack==0.5.6 diff --git a/tacker/db/migration/cli.py b/tacker/db/migration/cli.py index 8aa022b16..bdef6da1d 100644 --- a/tacker/db/migration/cli.py +++ b/tacker/db/migration/cli.py @@ -87,7 +87,7 @@ def validate_head_file(config): if len(script.get_heads()) > 1: alembic_util.err(_('Timeline branches unable to generate timeline')) - head_path = os.path.join(script.versions, HEAD_FILENAME) + head_path = os.path.join(str(script.versions), HEAD_FILENAME) if (os.path.isfile(head_path) and open(head_path).read().strip() == script.get_current_head()): return @@ -100,7 +100,7 @@ def update_head_file(config): if len(script.get_heads()) > 1: alembic_util.err(_('Timeline branches unable to generate timeline')) - head_path = os.path.join(script.versions, HEAD_FILENAME) + head_path = os.path.join(str(script.versions), HEAD_FILENAME) with open(head_path, 'w+') as f: f.write(script.get_current_head()) diff --git a/tacker/tests/base.py b/tacker/tests/base.py index 6ff60b544..7e7d9fd67 100644 --- a/tacker/tests/base.py +++ b/tacker/tests/base.py @@ -21,11 +21,11 @@ import logging import os import os.path import sys +from unittest import mock import weakref import eventlet.timeout import fixtures -import mock from oslo_config import cfg from oslo_messaging import conffixture as messaging_conffixture import testtools diff --git a/tacker/tests/unit/agent/linux/test_utils.py b/tacker/tests/unit/agent/linux/test_utils.py index 9d134dfdc..18e31e458 100644 --- a/tacker/tests/unit/agent/linux/test_utils.py +++ b/tacker/tests/unit/agent/linux/test_utils.py @@ -13,7 +13,7 @@ # under the License. -import mock +from unittest import mock import oslo_i18n diff --git a/tacker/tests/unit/api/test_v2_extension.py b/tacker/tests/unit/api/test_v2_extension.py index c5830937a..328f8c64f 100644 --- a/tacker/tests/unit/api/test_v2_extension.py +++ b/tacker/tests/unit/api/test_v2_extension.py @@ -14,7 +14,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 oslo_utils import uuidutils from webob import exc diff --git a/tacker/tests/unit/api/v1/test_resource.py b/tacker/tests/unit/api/v1/test_resource.py index bafc72f5b..cb60e5993 100644 --- a/tacker/tests/unit/api/v1/test_resource.py +++ b/tacker/tests/unit/api/v1/test_resource.py @@ -13,7 +13,8 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock + from webob import exc import webtest diff --git a/tacker/tests/unit/api/v1/test_resource_helper.py b/tacker/tests/unit/api/v1/test_resource_helper.py index c2cbdddf0..320daee0f 100644 --- a/tacker/tests/unit/api/v1/test_resource_helper.py +++ b/tacker/tests/unit/api/v1/test_resource_helper.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from tacker import manager diff --git a/tacker/tests/unit/api/v1/test_router.py b/tacker/tests/unit/api/v1/test_router.py index 9e14bbac3..9a1ace7c0 100644 --- a/tacker/tests/unit/api/v1/test_router.py +++ b/tacker/tests/unit/api/v1/test_router.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from oslo_serialization import jsonutils diff --git a/tacker/tests/unit/api/v1/test_vim.py b/tacker/tests/unit/api/v1/test_vim.py index 0dc8f2e92..c47bebeec 100644 --- a/tacker/tests/unit/api/v1/test_vim.py +++ b/tacker/tests/unit/api/v1/test_vim.py @@ -13,8 +13,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt -import mock import six from webob import exc diff --git a/tacker/tests/unit/api/v2/test_api_v2.py b/tacker/tests/unit/api/v2/test_api_v2.py index 0b1c4d98d..1a8135472 100644 --- a/tacker/tests/unit/api/v2/test_api_v2.py +++ b/tacker/tests/unit/api/v2/test_api_v2.py @@ -14,8 +14,8 @@ # under the License. import os +from unittest import mock -import mock from oslo_config import cfg from oslo_policy import policy as common_policy from oslo_utils import uuidutils diff --git a/tacker/tests/unit/base.py b/tacker/tests/unit/base.py index ac1a763ad..3165e8162 100644 --- a/tacker/tests/unit/base.py +++ b/tacker/tests/unit/base.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 oslo_config import fixture as config_fixture from requests_mock.contrib import fixture as requests_mock_fixture diff --git a/tacker/tests/unit/common/test_config.py b/tacker/tests/unit/common/test_config.py index 8d6eb2f74..37c09c486 100644 --- a/tacker/tests/unit/common/test_config.py +++ b/tacker/tests/unit/common/test_config.py @@ -14,8 +14,8 @@ # limitations under the License. import os +from unittest import mock -import mock from oslo_config import cfg from tacker.common import config diff --git a/tacker/tests/unit/common/test_csar_utils.py b/tacker/tests/unit/common/test_csar_utils.py index 8a7e8a45c..1e0fd4a96 100644 --- a/tacker/tests/unit/common/test_csar_utils.py +++ b/tacker/tests/unit/common/test_csar_utils.py @@ -12,10 +12,10 @@ # License for the specific language governing permissions and limitations # under the License. -import mock import os import shutil import testtools +from unittest import mock from tacker.common import csar_utils from tacker.common import exceptions diff --git a/tacker/tests/unit/common/test_log.py b/tacker/tests/unit/common/test_log.py index 2920f2d98..b1b41cd08 100644 --- a/tacker/tests/unit/common/test_log.py +++ b/tacker/tests/unit/common/test_log.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from tacker.common import log as call_log from tacker.tests import base diff --git a/tacker/tests/unit/conductor/conductorrpc/test_vnf_pkgm_rpc.py b/tacker/tests/unit/conductor/conductorrpc/test_vnf_pkgm_rpc.py index 407eb0737..f274fa7d3 100644 --- a/tacker/tests/unit/conductor/conductorrpc/test_vnf_pkgm_rpc.py +++ b/tacker/tests/unit/conductor/conductorrpc/test_vnf_pkgm_rpc.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from tacker.common.rpc import BackingOffClient from tacker.conductor.conductorrpc import vnf_pkgm_rpc diff --git a/tacker/tests/unit/conductor/test_conductor_server.py b/tacker/tests/unit/conductor/test_conductor_server.py index 608784836..02cd9fa38 100644 --- a/tacker/tests/unit/conductor/test_conductor_server.py +++ b/tacker/tests/unit/conductor/test_conductor_server.py @@ -14,12 +14,12 @@ # limitations under the License. import os -from oslo_config import cfg import shutil import sys +from unittest import mock from glance_store import exceptions as store_exceptions -import mock +from oslo_config import cfg from six.moves import urllib import six.moves.urllib.error as urlerr import yaml diff --git a/tacker/tests/unit/db/common_services/test_common_services_db_plugin.py b/tacker/tests/unit/db/common_services/test_common_services_db_plugin.py index 081c2e32f..d32b89e5f 100644 --- a/tacker/tests/unit/db/common_services/test_common_services_db_plugin.py +++ b/tacker/tests/unit/db/common_services/test_common_services_db_plugin.py @@ -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 timeutils diff --git a/tacker/tests/unit/db/test_db_migration.py b/tacker/tests/unit/db/test_db_migration.py index 748110c1d..35b5bb753 100644 --- a/tacker/tests/unit/db/test_db_migration.py +++ b/tacker/tests/unit/db/test_db_migration.py @@ -16,8 +16,8 @@ # @author Mark McClain (DreamHost) import sys +from unittest import mock -import mock from tacker.db.migration import cli from tacker.tests import base diff --git a/tacker/tests/unit/db/test_db_purge_delete.py b/tacker/tests/unit/db/test_db_purge_delete.py index 7201de9b4..7a3743842 100644 --- a/tacker/tests/unit/db/test_db_purge_delete.py +++ b/tacker/tests/unit/db/test_db_purge_delete.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from tacker.common import exceptions diff --git a/tacker/tests/unit/extensions/test_common_services.py b/tacker/tests/unit/extensions/test_common_services.py index 672788cb8..e1c0a6531 100644 --- a/tacker/tests/unit/extensions/test_common_services.py +++ b/tacker/tests/unit/extensions/test_common_services.py @@ -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 timeutils diff --git a/tacker/tests/unit/glance_store/test_store.py b/tacker/tests/unit/glance_store/test_store.py index f0fac2e58..88df4de0a 100644 --- a/tacker/tests/unit/glance_store/test_store.py +++ b/tacker/tests/unit/glance_store/test_store.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock import glance_store from six.moves import urllib diff --git a/tacker/tests/unit/nfvo/drivers/vim/test_kubernetes_driver.py b/tacker/tests/unit/nfvo/drivers/vim/test_kubernetes_driver.py index 649b595a5..a76478596 100644 --- a/tacker/tests/unit/nfvo/drivers/vim/test_kubernetes_driver.py +++ b/tacker/tests/unit/nfvo/drivers/vim/test_kubernetes_driver.py @@ -13,7 +13,8 @@ # under the License. from collections import namedtuple -import mock +from unittest import mock + from oslo_config import cfg from tacker import context as t_context diff --git a/tacker/tests/unit/nfvo/drivers/vim/test_openstack_driver.py b/tacker/tests/unit/nfvo/drivers/vim/test_openstack_driver.py index 3def1a9d8..28f2e6ad0 100644 --- a/tacker/tests/unit/nfvo/drivers/vim/test_openstack_driver.py +++ b/tacker/tests/unit/nfvo/drivers/vim/test_openstack_driver.py @@ -14,9 +14,9 @@ # under the License. import os +from unittest import mock from keystoneauth1 import exceptions -import mock from oslo_config import cfg from tacker import context as t_context diff --git a/tacker/tests/unit/nfvo/drivers/vnffg/sfc_drivers/networking-sfc/test_n_sfc.py b/tacker/tests/unit/nfvo/drivers/vnffg/sfc_drivers/networking-sfc/test_n_sfc.py index 7b224e9f2..6f652b950 100644 --- a/tacker/tests/unit/nfvo/drivers/vnffg/sfc_drivers/networking-sfc/test_n_sfc.py +++ b/tacker/tests/unit/nfvo/drivers/vnffg/sfc_drivers/networking-sfc/test_n_sfc.py @@ -11,7 +11,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from oslo_utils import uuidutils diff --git a/tacker/tests/unit/nfvo/test_nfvo_plugin.py b/tacker/tests/unit/nfvo/test_nfvo_plugin.py index c3da8fd7b..644400cab 100644 --- a/tacker/tests/unit/nfvo/test_nfvo_plugin.py +++ b/tacker/tests/unit/nfvo/test_nfvo_plugin.py @@ -15,11 +15,11 @@ import codecs from datetime import datetime -import mock import os -from oslo_utils import uuidutils +from unittest import mock +from unittest.mock import patch -from mock import patch +from oslo_utils import uuidutils from tacker.common import exceptions from tacker import context diff --git a/tacker/tests/unit/objects/test_vnf_deployment_flavour.py b/tacker/tests/unit/objects/test_vnf_deployment_flavour.py index d35f330c4..4a24265f1 100644 --- a/tacker/tests/unit/objects/test_vnf_deployment_flavour.py +++ b/tacker/tests/unit/objects/test_vnf_deployment_flavour.py @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import mock +from unittest import mock from tacker.common import exceptions from tacker import context diff --git a/tacker/tests/unit/objects/test_vnf_instance.py b/tacker/tests/unit/objects/test_vnf_instance.py index ccc8e6df0..175acd743 100644 --- a/tacker/tests/unit/objects/test_vnf_instance.py +++ b/tacker/tests/unit/objects/test_vnf_instance.py @@ -13,16 +13,16 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock + from tacker.common import exceptions from tacker import context +from tacker.db import api as sqlalchemy_api from tacker import objects from tacker.tests.unit.db.base import SqlTestCase from tacker.tests.unit.objects import fakes from tacker.tests import uuidsentinel -from tacker.db import api as sqlalchemy_api - get_engine = sqlalchemy_api.get_engine diff --git a/tacker/tests/unit/objects/test_vnf_package.py b/tacker/tests/unit/objects/test_vnf_package.py index 91af07137..02f623a61 100644 --- a/tacker/tests/unit/objects/test_vnf_package.py +++ b/tacker/tests/unit/objects/test_vnf_package.py @@ -13,7 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -import mock +from unittest import mock + from oslo_utils import uuidutils from tacker.common import exceptions diff --git a/tacker/tests/unit/objects/test_vnf_resource.py b/tacker/tests/unit/objects/test_vnf_resource.py index 57f83dbc1..04026228e 100644 --- a/tacker/tests/unit/objects/test_vnf_resource.py +++ b/tacker/tests/unit/objects/test_vnf_resource.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from tacker.common import exceptions from tacker import context diff --git a/tacker/tests/unit/test_alarm_receiver.py b/tacker/tests/unit/test_alarm_receiver.py index 93d99ffb2..211664e59 100644 --- a/tacker/tests/unit/test_alarm_receiver.py +++ b/tacker/tests/unit/test_alarm_receiver.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_serialization import jsonutils from webob import Request diff --git a/tacker/tests/unit/test_context.py b/tacker/tests/unit/test_context.py index 7dc9c324e..aef92e1af 100644 --- a/tacker/tests/unit/test_context.py +++ b/tacker/tests/unit/test_context.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_context import context as oslo_context from testtools import matchers diff --git a/tacker/tests/unit/test_policy.py b/tacker/tests/unit/test_policy.py index 05175bdc1..177c0caba 100644 --- a/tacker/tests/unit/test_policy.py +++ b/tacker/tests/unit/test_policy.py @@ -15,8 +15,9 @@ """Test of Policy Engine For Tacker""" +from unittest import mock + import fixtures -import mock import six from oslo_policy import policy as common_policy diff --git a/tacker/tests/unit/test_wsgi.py b/tacker/tests/unit/test_wsgi.py index 5923a8b5a..3966136ee 100644 --- a/tacker/tests/unit/test_wsgi.py +++ b/tacker/tests/unit/test_wsgi.py @@ -14,10 +14,11 @@ # under the License. import os +from unittest import mock + import oslo_i18n import socket -import mock from oslo_config import cfg import six.moves.urllib.request as urllibrequest import testtools diff --git a/tacker/tests/unit/tests/test_post_mortem_debug.py b/tacker/tests/unit/tests/test_post_mortem_debug.py index e54508851..43d67b050 100644 --- a/tacker/tests/unit/tests/test_post_mortem_debug.py +++ b/tacker/tests/unit/tests/test_post_mortem_debug.py @@ -14,8 +14,8 @@ # under the License. import sys +from unittest import mock -import mock from six import moves from tacker.tests import base diff --git a/tacker/tests/unit/vnflcm/test_controller.py b/tacker/tests/unit/vnflcm/test_controller.py index 64bd2c70a..cad7ffb41 100644 --- a/tacker/tests/unit/vnflcm/test_controller.py +++ b/tacker/tests/unit/vnflcm/test_controller.py @@ -12,9 +12,9 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. +from unittest import mock import ddt -import mock from oslo_serialization import jsonutils from six.moves import http_client from webob import exc diff --git a/tacker/tests/unit/vnflcm/test_vnflcm_driver.py b/tacker/tests/unit/vnflcm/test_vnflcm_driver.py index 98bc412d7..1829e1458 100644 --- a/tacker/tests/unit/vnflcm/test_vnflcm_driver.py +++ b/tacker/tests/unit/vnflcm/test_vnflcm_driver.py @@ -14,10 +14,11 @@ # limitations under the License. import os import shutil +from unittest import mock import fixtures -import mock from oslo_config import cfg + from tacker.common import exceptions from tacker.common import utils from tacker import context diff --git a/tacker/tests/unit/vnfm/infra_drivers/openstack/test_openstack.py b/tacker/tests/unit/vnfm/infra_drivers/openstack/test_openstack.py index 26d8f48c9..8281fc271 100644 --- a/tacker/tests/unit/vnfm/infra_drivers/openstack/test_openstack.py +++ b/tacker/tests/unit/vnfm/infra_drivers/openstack/test_openstack.py @@ -15,8 +15,7 @@ import codecs import os - -import mock +from unittest import mock import yaml from oslo_serialization import jsonutils diff --git a/tacker/tests/unit/vnfm/infra_drivers/openstack/test_openstack_driver.py b/tacker/tests/unit/vnfm/infra_drivers/openstack/test_openstack_driver.py index 9aba49ea1..667f1a0c0 100644 --- a/tacker/tests/unit/vnfm/infra_drivers/openstack/test_openstack_driver.py +++ b/tacker/tests/unit/vnfm/infra_drivers/openstack/test_openstack_driver.py @@ -13,13 +13,14 @@ # License for the specific language governing permissions and limitations # under the License. -import ddt import importlib import json -import mock import os -import requests import tempfile +from unittest import mock + +import ddt +import requests import yaml from tacker.common import exceptions diff --git a/tacker/tests/unit/vnfm/infra_drivers/openstack/test_vdu.py b/tacker/tests/unit/vnfm/infra_drivers/openstack/test_vdu.py index 9cc18af21..2fa2ec9eb 100644 --- a/tacker/tests/unit/vnfm/infra_drivers/openstack/test_vdu.py +++ b/tacker/tests/unit/vnfm/infra_drivers/openstack/test_vdu.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from tacker import context from tacker.db.common_services import common_services_db_plugin diff --git a/tacker/tests/unit/vnfm/monitor_drivers/http_ping/test_http_ping.py b/tacker/tests/unit/vnfm/monitor_drivers/http_ping/test_http_ping.py index 63bd35a65..98a93f9a0 100644 --- a/tacker/tests/unit/vnfm/monitor_drivers/http_ping/test_http_ping.py +++ b/tacker/tests/unit/vnfm/monitor_drivers/http_ping/test_http_ping.py @@ -12,7 +12,8 @@ # under the License. # -import mock +from unittest import mock + import six.moves.urllib.error as urlerr import testtools diff --git a/tacker/tests/unit/vnfm/monitor_drivers/ping/test_ping.py b/tacker/tests/unit/vnfm/monitor_drivers/ping/test_ping.py index ac5d62cf1..b6a574746 100644 --- a/tacker/tests/unit/vnfm/monitor_drivers/ping/test_ping.py +++ b/tacker/tests/unit/vnfm/monitor_drivers/ping/test_ping.py @@ -12,8 +12,8 @@ # under the License. # -import mock import testtools +from unittest import mock from tacker.vnfm.monitor_drivers.ping import ping diff --git a/tacker/tests/unit/vnfm/monitor_drivers/zabbix/test_zabbix.py b/tacker/tests/unit/vnfm/monitor_drivers/zabbix/test_zabbix.py index 0bf499755..8d7c547b6 100644 --- a/tacker/tests/unit/vnfm/monitor_drivers/zabbix/test_zabbix.py +++ b/tacker/tests/unit/vnfm/monitor_drivers/zabbix/test_zabbix.py @@ -12,9 +12,9 @@ # under the License. # -import mock from tacker.vnfm.monitor_drivers.zabbix import zabbix import testtools +from unittest import mock class TestVNFMonitorZabbix(testtools.TestCase): diff --git a/tacker/tests/unit/vnfm/policy_actions/autoscaling/test_autoscaling.py b/tacker/tests/unit/vnfm/policy_actions/autoscaling/test_autoscaling.py index 11605df6a..e49447969 100644 --- a/tacker/tests/unit/vnfm/policy_actions/autoscaling/test_autoscaling.py +++ b/tacker/tests/unit/vnfm/policy_actions/autoscaling/test_autoscaling.py @@ -12,8 +12,8 @@ # License for the specific language governing permissions and limitations # under the License. -import mock import testtools +from unittest import mock from tacker import context from tacker.db.common_services import common_services_db_plugin diff --git a/tacker/tests/unit/vnfm/policy_actions/log/test_log.py b/tacker/tests/unit/vnfm/policy_actions/log/test_log.py index 648dc808a..bfc5831d8 100644 --- a/tacker/tests/unit/vnfm/policy_actions/log/test_log.py +++ b/tacker/tests/unit/vnfm/policy_actions/log/test_log.py @@ -12,8 +12,8 @@ # License for the specific language governing permissions and limitations # under the License. -import mock import testtools +from unittest import mock from tacker import context from tacker.db.common_services import common_services_db_plugin diff --git a/tacker/tests/unit/vnfm/policy_actions/respawn/test_respawn.py b/tacker/tests/unit/vnfm/policy_actions/respawn/test_respawn.py index 9a6941ec0..bfe03ec0d 100644 --- a/tacker/tests/unit/vnfm/policy_actions/respawn/test_respawn.py +++ b/tacker/tests/unit/vnfm/policy_actions/respawn/test_respawn.py @@ -12,8 +12,8 @@ # License for the specific language governing permissions and limitations # under the License. -import mock import testtools +from unittest import mock from tacker.common import clients from tacker import context diff --git a/tacker/tests/unit/vnfm/policy_actions/vdu_autoheal/test_vdu_autoheal.py b/tacker/tests/unit/vnfm/policy_actions/vdu_autoheal/test_vdu_autoheal.py index 02360f0fb..634e45f22 100644 --- a/tacker/tests/unit/vnfm/policy_actions/vdu_autoheal/test_vdu_autoheal.py +++ b/tacker/tests/unit/vnfm/policy_actions/vdu_autoheal/test_vdu_autoheal.py @@ -13,8 +13,8 @@ # from datetime import datetime +from unittest import mock -import mock from oslo_utils import uuidutils from tacker import context diff --git a/tacker/tests/unit/vnfm/test_k8s_plugin.py b/tacker/tests/unit/vnfm/test_k8s_plugin.py index a85cf8a4a..03a17f2ad 100644 --- a/tacker/tests/unit/vnfm/test_k8s_plugin.py +++ b/tacker/tests/unit/vnfm/test_k8s_plugin.py @@ -14,10 +14,10 @@ # under the License. from datetime import datetime - -import mock +from unittest import mock from oslo_utils import uuidutils + from tacker import context from tacker.db.common_services import common_services_db_plugin from tacker.db.nfvo import nfvo_db diff --git a/tacker/tests/unit/vnfm/test_monitor.py b/tacker/tests/unit/vnfm/test_monitor.py index 9e3dbac57..712c5d5b9 100644 --- a/tacker/tests/unit/vnfm/test_monitor.py +++ b/tacker/tests/unit/vnfm/test_monitor.py @@ -12,7 +12,8 @@ # under the License. # -import mock +from unittest import mock + from oslo_serialization import jsonutils from oslo_utils import timeutils import testtools diff --git a/tacker/tests/unit/vnfm/test_plugin.py b/tacker/tests/unit/vnfm/test_plugin.py index caa77aae4..666b7e71e 100644 --- a/tacker/tests/unit/vnfm/test_plugin.py +++ b/tacker/tests/unit/vnfm/test_plugin.py @@ -14,10 +14,10 @@ # under the License. from datetime import datetime +from unittest import mock +from unittest.mock import patch import ddt -import mock -from mock import patch from oslo_utils import uuidutils import yaml diff --git a/tacker/tests/unit/vnfm/test_vim_client.py b/tacker/tests/unit/vnfm/test_vim_client.py index 89b1979d0..aad325923 100644 --- a/tacker/tests/unit/vnfm/test_vim_client.py +++ b/tacker/tests/unit/vnfm/test_vim_client.py @@ -10,8 +10,8 @@ # License for the specific language governing permissions and limitations # under the License. -import mock from sqlalchemy.orm import exc as orm_exc +from unittest import mock from tacker.extensions import nfvo from tacker import manager diff --git a/tacker/tests/unit/vnfpkgm/test_controller.py b/tacker/tests/unit/vnfpkgm/test_controller.py index e4a0d4725..5f158e96e 100644 --- a/tacker/tests/unit/vnfpkgm/test_controller.py +++ b/tacker/tests/unit/vnfpkgm/test_controller.py @@ -12,8 +12,9 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt -import mock from oslo_serialization import jsonutils from six.moves import http_client from six.moves import urllib diff --git a/test-requirements.txt b/test-requirements.txt index 4f531820d..6df2ee3dd 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -9,7 +9,6 @@ ddt>=1.0.1 # MIT doc8>=0.6.0 # Apache-2.0 fixtures>=3.0.0 # Apache-2.0/BSD hacking>=3.0.1,<3.1.0 # Apache-2.0 -mock>=3.0.0 # BSD python-subunit>=1.0.0 # Apache-2.0/BSD python-tackerclient>=0.8.0 # Apache-2.0 oslotest>=3.2.0 # Apache-2.0