From 8a36ad5f878add69c434c4e72c06bb198cfa3f7f Mon Sep 17 00:00:00 2001 From: zhangbailin Date: Sun, 26 Apr 2020 17:03:13 +0800 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. The remainder was auto-generated with the following (hacky) script, with one or two manual tweaks after the fact: import glob for path in glob.glob('watcher/tests/**/*.py', recursive=True): with open(path) as fh: lines = fh.readlines() if 'import mock\n' not in lines: continue import_group_found = False create_first_party_group = False for num, line in enumerate(lines): line = line.strip() if line.startswith('import ') or line.startswith('from '): tokens = line.split() for lib in ( 'ddt', 'six', 'webob', 'fixtures', 'testtools' 'neutron', 'cinder', 'ironic', 'keystone', 'oslo', ): if lib in tokens[1]: create_first_party_group = True break if create_first_party_group: break import_group_found = True if not import_group_found: continue if line.startswith('import ') or line.startswith('from '): tokens = line.split() if tokens[1] > 'unittest': break elif tokens[1] == 'unittest' and ( len(tokens) == 2 or tokens[4] > 'mock' ): break elif not line: break if create_first_party_group: lines.insert(num, 'from unittest import mock\n\n') else: lines.insert(num, 'from unittest import mock\n') del lines[lines.index('import mock\n')] with open(path, 'w+') as fh: fh.writelines(lines) Co-Authored-By: Sean McGinnis Change-Id: Icf35d3a6c10c529e07d1a4edaa36f504e5bf553a --- test-requirements.txt | 1 - watcher/tests/api/base.py | 2 +- watcher/tests/api/test_hooks.py | 3 ++- watcher/tests/api/test_scheduling.py | 2 +- watcher/tests/api/v1/test_actions.py | 2 +- watcher/tests/api/v1/test_actions_plans.py | 2 +- watcher/tests/api/v1/test_audit_templates.py | 2 +- watcher/tests/api/v1/test_audits.py | 2 +- watcher/tests/api/v1/test_data_model.py | 2 +- watcher/tests/api/v1/test_strategies.py | 2 +- watcher/tests/api/v1/test_types.py | 2 +- watcher/tests/api/v1/test_webhooks.py | 2 +- .../tests/applier/action_plan/test_default_action_handler.py | 2 +- watcher/tests/applier/actions/test_change_node_power_state.py | 2 +- .../tests/applier/actions/test_change_nova_service_state.py | 2 +- watcher/tests/applier/actions/test_migration.py | 2 +- watcher/tests/applier/actions/test_resize.py | 2 +- watcher/tests/applier/actions/test_sleep.py | 2 +- watcher/tests/applier/actions/test_volume_migration.py | 2 +- .../applier/messaging/test_trigger_action_plan_endpoint.py | 2 +- watcher/tests/applier/test_applier_manager.py | 2 +- watcher/tests/applier/test_rpcapi.py | 3 ++- watcher/tests/applier/test_sync.py | 2 +- .../applier/workflow_engine/test_default_workflow_engine.py | 2 +- .../applier/workflow_engine/test_taskflow_action_container.py | 2 +- watcher/tests/base.py | 2 +- watcher/tests/cmd/test_api.py | 2 +- watcher/tests/cmd/test_applier.py | 2 +- watcher/tests/cmd/test_db_manage.py | 2 +- watcher/tests/cmd/test_decision_engine.py | 2 +- watcher/tests/common/loader/test_loader.py | 2 +- watcher/tests/common/test_cinder_helper.py | 2 +- watcher/tests/common/test_clients.py | 3 ++- watcher/tests/common/test_ironic_helper.py | 2 +- watcher/tests/common/test_nova_helper.py | 2 +- watcher/tests/common/test_placement_helper.py | 2 +- watcher/tests/common/test_service.py | 2 +- watcher/tests/conf/test_list_opts.py | 3 ++- watcher/tests/db/test_purge.py | 3 ++- watcher/tests/decision_engine/audit/test_audit_handlers.py | 2 +- watcher/tests/decision_engine/cluster/test_cinder_cdmc.py | 2 +- .../cluster/test_cluster_data_model_collector.py | 2 +- watcher/tests/decision_engine/cluster/test_nova_cdmc.py | 2 +- .../datasources/grafana_translators/test_base.py | 2 +- .../datasources/grafana_translators/test_influxdb.py | 2 +- watcher/tests/decision_engine/datasources/test_base.py | 3 ++- .../decision_engine/datasources/test_ceilometer_helper.py | 2 +- .../tests/decision_engine/datasources/test_gnocchi_helper.py | 3 ++- .../tests/decision_engine/datasources/test_grafana_helper.py | 2 +- watcher/tests/decision_engine/datasources/test_manager.py | 2 +- .../tests/decision_engine/datasources/test_monasca_helper.py | 3 ++- watcher/tests/decision_engine/loading/test_collector_loader.py | 2 +- .../decision_engine/loading/test_default_strategy_loader.py | 2 +- watcher/tests/decision_engine/loading/test_goal_loader.py | 2 +- watcher/tests/decision_engine/messaging/test_audit_endpoint.py | 2 +- .../decision_engine/messaging/test_data_model_endpoint.py | 3 ++- .../tests/decision_engine/model/faker_cluster_and_metrics.py | 2 +- watcher/tests/decision_engine/model/faker_cluster_state.py | 2 +- .../model/notification/test_cinder_notifications.py | 2 +- .../decision_engine/model/notification/test_notifications.py | 2 +- .../model/notification/test_nova_notifications.py | 2 +- watcher/tests/decision_engine/model/test_model.py | 2 +- .../planner/test_node_resource_consolidation.py | 2 +- watcher/tests/decision_engine/planner/test_weight_planner.py | 2 +- .../planner/test_workload_stabilization_planner.py | 2 +- watcher/tests/decision_engine/scope/test_baremetal.py | 2 +- watcher/tests/decision_engine/scope/test_compute.py | 2 +- watcher/tests/decision_engine/scope/test_storage.py | 2 +- .../tests/decision_engine/solution/test_default_solution.py | 2 +- .../decision_engine/strategy/context/test_strategy_context.py | 2 +- .../strategy/selector/test_strategy_selector.py | 2 +- .../tests/decision_engine/strategy/strategies/test_actuator.py | 2 +- watcher/tests/decision_engine/strategy/strategies/test_base.py | 2 +- .../strategy/strategies/test_basic_consolidation.py | 2 +- .../decision_engine/strategy/strategies/test_dummy_strategy.py | 2 +- .../strategy/strategies/test_dummy_with_scorer.py | 2 +- .../strategy/strategies/test_host_maintenance.py | 2 +- .../strategy/strategies/test_node_resource_consolidation.py | 2 +- .../decision_engine/strategy/strategies/test_noisy_neighbor.py | 2 +- .../strategy/strategies/test_outlet_temp_control.py | 2 +- .../decision_engine/strategy/strategies/test_saving_energy.py | 2 +- .../strategy/strategies/test_storage_capacity_balance.py | 2 +- .../strategy/strategies/test_strategy_endpoint.py | 2 +- .../strategy/strategies/test_uniform_airflow.py | 2 +- .../strategy/strategies/test_vm_workload_consolidation.py | 2 +- .../strategy/strategies/test_workload_balance.py | 2 +- .../strategy/strategies/test_workload_stabilization.py | 2 +- .../decision_engine/strategy/strategies/test_zone_migration.py | 2 +- watcher/tests/decision_engine/test_gmr.py | 2 +- watcher/tests/decision_engine/test_rpcapi.py | 3 ++- watcher/tests/decision_engine/test_scheduling.py | 2 +- watcher/tests/decision_engine/test_sync.py | 2 +- watcher/tests/fakes.py | 2 +- watcher/tests/notifications/test_action_notification.py | 3 ++- watcher/tests/notifications/test_action_plan_notification.py | 3 ++- watcher/tests/notifications/test_audit_notification.py | 3 ++- watcher/tests/notifications/test_notification.py | 2 +- watcher/tests/notifications/test_service_notifications.py | 2 +- watcher/tests/objects/test_action.py | 2 +- watcher/tests/objects/test_action_description.py | 2 +- watcher/tests/objects/test_action_plan.py | 2 +- watcher/tests/objects/test_audit.py | 2 +- watcher/tests/objects/test_audit_template.py | 2 +- watcher/tests/objects/test_efficacy_indicator.py | 2 +- watcher/tests/objects/test_goal.py | 2 +- watcher/tests/objects/test_objects.py | 2 +- watcher/tests/objects/test_scoring_engine.py | 2 +- watcher/tests/objects/test_service.py | 2 +- watcher/tests/objects/test_strategy.py | 2 +- watcher/tests/test_threading.py | 2 +- 110 files changed, 122 insertions(+), 110 deletions(-) diff --git a/test-requirements.txt b/test-requirements.txt index a4d6a5d9e..1eda92b76 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -6,7 +6,6 @@ coverage>=4.5.1 # Apache-2.0 doc8>=0.8.0 # Apache-2.0 freezegun>=0.3.10 # Apache-2.0 hacking>=3.0.1,<3.1.0 # Apache-2.0 -mock>=2.0.0 # BSD oslotest>=3.3.0 # Apache-2.0 os-testr>=1.0.0 # Apache-2.0 testscenarios>=0.5.0 # Apache-2.0/BSD diff --git a/watcher/tests/api/base.py b/watcher/tests/api/base.py index 9d05824cb..389b87d00 100644 --- a/watcher/tests/api/base.py +++ b/watcher/tests/api/base.py @@ -23,7 +23,7 @@ # NOTE(deva): import auth_token so we can override a config option import copy -import mock +from unittest import mock from urllib import parse as urlparse from oslo_config import cfg diff --git a/watcher/tests/api/test_hooks.py b/watcher/tests/api/test_hooks.py index b2ce49f2d..1653038b3 100644 --- a/watcher/tests/api/test_hooks.py +++ b/watcher/tests/api/test_hooks.py @@ -14,7 +14,8 @@ """Tests for the Pecan API hooks.""" -import mock +from unittest import mock + from oslo_config import cfg import oslo_messaging as messaging from oslo_serialization import jsonutils diff --git a/watcher/tests/api/test_scheduling.py b/watcher/tests/api/test_scheduling.py index b857afa46..bdbcb900e 100644 --- a/watcher/tests/api/test_scheduling.py +++ b/watcher/tests/api/test_scheduling.py @@ -15,7 +15,7 @@ from apscheduler.schedulers import background import datetime import freezegun -import mock +from unittest import mock from watcher.api import scheduling from watcher.notifications import service diff --git a/watcher/tests/api/v1/test_actions.py b/watcher/tests/api/v1/test_actions.py index b70861465..6aaf3d719 100644 --- a/watcher/tests/api/v1/test_actions.py +++ b/watcher/tests/api/v1/test_actions.py @@ -12,7 +12,7 @@ import datetime import itertools -import mock +from unittest import mock from oslo_config import cfg from oslo_serialization import jsonutils diff --git a/watcher/tests/api/v1/test_actions_plans.py b/watcher/tests/api/v1/test_actions_plans.py index 6011dda91..4b227a43a 100644 --- a/watcher/tests/api/v1/test_actions_plans.py +++ b/watcher/tests/api/v1/test_actions_plans.py @@ -12,7 +12,7 @@ import datetime import itertools -import mock +from unittest import mock from oslo_config import cfg from oslo_serialization import jsonutils diff --git a/watcher/tests/api/v1/test_audit_templates.py b/watcher/tests/api/v1/test_audit_templates.py index 55002bc04..91d7c2885 100644 --- a/watcher/tests/api/v1/test_audit_templates.py +++ b/watcher/tests/api/v1/test_audit_templates.py @@ -12,7 +12,7 @@ import datetime import itertools -import mock +from unittest import mock from urllib import parse as urlparse from webtest.app import AppError diff --git a/watcher/tests/api/v1/test_audits.py b/watcher/tests/api/v1/test_audits.py index 34603e655..c0a486ee5 100644 --- a/watcher/tests/api/v1/test_audits.py +++ b/watcher/tests/api/v1/test_audits.py @@ -13,7 +13,7 @@ import datetime from dateutil import tz import itertools -import mock +from unittest import mock from urllib import parse as urlparse from oslo_config import cfg diff --git a/watcher/tests/api/v1/test_data_model.py b/watcher/tests/api/v1/test_data_model.py index ceca97578..867b14841 100644 --- a/watcher/tests/api/v1/test_data_model.py +++ b/watcher/tests/api/v1/test_data_model.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 oslo_serialization import jsonutils diff --git a/watcher/tests/api/v1/test_strategies.py b/watcher/tests/api/v1/test_strategies.py index 33442b0f2..3cf9a11da 100644 --- a/watcher/tests/api/v1/test_strategies.py +++ b/watcher/tests/api/v1/test_strategies.py @@ -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 urllib import parse as urlparse from oslo_config import cfg diff --git a/watcher/tests/api/v1/test_types.py b/watcher/tests/api/v1/test_types.py index 2a6a34e15..95f50c537 100644 --- a/watcher/tests/api/v1/test_types.py +++ b/watcher/tests/api/v1/test_types.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock import webtest import wsme from wsme import types as wtypes diff --git a/watcher/tests/api/v1/test_webhooks.py b/watcher/tests/api/v1/test_webhooks.py index 67a4ff04a..c3b8786df 100644 --- a/watcher/tests/api/v1/test_webhooks.py +++ b/watcher/tests/api/v1/test_webhooks.py @@ -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 watcher.decision_engine import rpcapi as deapi from watcher import objects diff --git a/watcher/tests/applier/action_plan/test_default_action_handler.py b/watcher/tests/applier/action_plan/test_default_action_handler.py index 7aadee9d0..d3f25583b 100755 --- a/watcher/tests/applier/action_plan/test_default_action_handler.py +++ b/watcher/tests/applier/action_plan/test_default_action_handler.py @@ -15,7 +15,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import mock +from unittest import mock from watcher.applier.action_plan import default from watcher.applier import default as ap_applier diff --git a/watcher/tests/applier/actions/test_change_node_power_state.py b/watcher/tests/applier/actions/test_change_node_power_state.py index 7c2607de7..a3b045c8f 100644 --- a/watcher/tests/applier/actions/test_change_node_power_state.py +++ b/watcher/tests/applier/actions/test_change_node_power_state.py @@ -14,7 +14,7 @@ # limitations under the License. import jsonschema -import mock +from unittest import mock from watcher.applier.actions import base as baction from watcher.applier.actions import change_node_power_state diff --git a/watcher/tests/applier/actions/test_change_nova_service_state.py b/watcher/tests/applier/actions/test_change_nova_service_state.py index 949760d83..6188e5932 100644 --- a/watcher/tests/applier/actions/test_change_nova_service_state.py +++ b/watcher/tests/applier/actions/test_change_nova_service_state.py @@ -14,7 +14,7 @@ # limitations under the License. import jsonschema -import mock +from unittest import mock from watcher.applier.actions import base as baction from watcher.applier.actions import change_nova_service_state diff --git a/watcher/tests/applier/actions/test_migration.py b/watcher/tests/applier/actions/test_migration.py index 95d3d4b4d..578e1d713 100644 --- a/watcher/tests/applier/actions/test_migration.py +++ b/watcher/tests/applier/actions/test_migration.py @@ -14,7 +14,7 @@ # limitations under the License. import jsonschema -import mock +from unittest import mock from watcher.applier.actions import base as baction from watcher.applier.actions import migration diff --git a/watcher/tests/applier/actions/test_resize.py b/watcher/tests/applier/actions/test_resize.py index 75709c9b4..5cd23801f 100644 --- a/watcher/tests/applier/actions/test_resize.py +++ b/watcher/tests/applier/actions/test_resize.py @@ -14,7 +14,7 @@ # limitations under the License. import jsonschema -import mock +from unittest import mock from watcher.applier.actions import base as baction from watcher.applier.actions import resize diff --git a/watcher/tests/applier/actions/test_sleep.py b/watcher/tests/applier/actions/test_sleep.py index 0b83c8f39..76d1b63c1 100644 --- a/watcher/tests/applier/actions/test_sleep.py +++ b/watcher/tests/applier/actions/test_sleep.py @@ -15,7 +15,7 @@ import jsonschema -import mock +from unittest import mock from watcher.applier.actions import sleep from watcher.tests import base diff --git a/watcher/tests/applier/actions/test_volume_migration.py b/watcher/tests/applier/actions/test_volume_migration.py index 2381f20f8..aa0081d2b 100644 --- a/watcher/tests/applier/actions/test_volume_migration.py +++ b/watcher/tests/applier/actions/test_volume_migration.py @@ -13,7 +13,7 @@ # limitations under the License. import jsonschema -import mock +from unittest import mock from watcher.applier.actions import base as baction from watcher.applier.actions import volume_migration diff --git a/watcher/tests/applier/messaging/test_trigger_action_plan_endpoint.py b/watcher/tests/applier/messaging/test_trigger_action_plan_endpoint.py index eac3a0f67..f73face1c 100644 --- a/watcher/tests/applier/messaging/test_trigger_action_plan_endpoint.py +++ b/watcher/tests/applier/messaging/test_trigger_action_plan_endpoint.py @@ -18,7 +18,7 @@ # -import mock +from unittest import mock from watcher.applier.messaging import trigger from watcher.common import utils diff --git a/watcher/tests/applier/test_applier_manager.py b/watcher/tests/applier/test_applier_manager.py index bfa67504e..cc38ad788 100644 --- a/watcher/tests/applier/test_applier_manager.py +++ b/watcher/tests/applier/test_applier_manager.py @@ -16,7 +16,7 @@ # limitations under the License. # -import mock +from unittest import mock import oslo_messaging as om from watcher.applier import manager as applier_manager diff --git a/watcher/tests/applier/test_rpcapi.py b/watcher/tests/applier/test_rpcapi.py index acf6c805c..4885b7150 100644 --- a/watcher/tests/applier/test_rpcapi.py +++ b/watcher/tests/applier/test_rpcapi.py @@ -17,7 +17,8 @@ # limitations under the License. # -import mock +from unittest import mock + import oslo_messaging as om from watcher.applier import rpcapi diff --git a/watcher/tests/applier/test_sync.py b/watcher/tests/applier/test_sync.py index 9c5c0b87f..126055bf1 100644 --- a/watcher/tests/applier/test_sync.py +++ b/watcher/tests/applier/test_sync.py @@ -16,7 +16,7 @@ # 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 oslo_utils import uuidutils diff --git a/watcher/tests/applier/workflow_engine/test_default_workflow_engine.py b/watcher/tests/applier/workflow_engine/test_default_workflow_engine.py index 100d21a69..099e930b3 100644 --- a/watcher/tests/applier/workflow_engine/test_default_workflow_engine.py +++ b/watcher/tests/applier/workflow_engine/test_default_workflow_engine.py @@ -17,7 +17,7 @@ # limitations under the License. # import abc -import mock +from unittest import mock from watcher.applier.actions import base as abase from watcher.applier.actions import factory diff --git a/watcher/tests/applier/workflow_engine/test_taskflow_action_container.py b/watcher/tests/applier/workflow_engine/test_taskflow_action_container.py index 1862d64d3..b8f43636c 100644 --- a/watcher/tests/applier/workflow_engine/test_taskflow_action_container.py +++ b/watcher/tests/applier/workflow_engine/test_taskflow_action_container.py @@ -17,7 +17,7 @@ # limitations under the License. # import eventlet -import mock +from unittest import mock from watcher.applier.workflow_engine import default as tflow from watcher.common import clients diff --git a/watcher/tests/base.py b/watcher/tests/base.py index 1e4b9bb2e..1dda3f17c 100644 --- a/watcher/tests/base.py +++ b/watcher/tests/base.py @@ -15,8 +15,8 @@ import copy import os +from unittest import mock -import mock from oslo_config import cfg from oslo_log import log from oslo_messaging import conffixture diff --git a/watcher/tests/cmd/test_api.py b/watcher/tests/cmd/test_api.py index 1ef476536..2d57c9cb4 100644 --- a/watcher/tests/cmd/test_api.py +++ b/watcher/tests/cmd/test_api.py @@ -15,8 +15,8 @@ # limitations under the License. import types +from unittest import mock -import mock from oslo_config import cfg from oslo_service import wsgi from pecan.testing import load_test_app diff --git a/watcher/tests/cmd/test_applier.py b/watcher/tests/cmd/test_applier.py index 6ca43338a..6fca8fa62 100644 --- a/watcher/tests/cmd/test_applier.py +++ b/watcher/tests/cmd/test_applier.py @@ -15,8 +15,8 @@ # limitations under the License. import types +from unittest import mock -import mock from oslo_config import cfg from oslo_service import service from watcher.applier import sync diff --git a/watcher/tests/cmd/test_db_manage.py b/watcher/tests/cmd/test_db_manage.py index f2e85eebf..6ff030e5a 100644 --- a/watcher/tests/cmd/test_db_manage.py +++ b/watcher/tests/cmd/test_db_manage.py @@ -15,8 +15,8 @@ # limitations under the License. import sys +from unittest import mock -import mock from oslo_config import cfg from watcher.cmd import dbmanage diff --git a/watcher/tests/cmd/test_decision_engine.py b/watcher/tests/cmd/test_decision_engine.py index 66d318ee4..81ac6f2c7 100644 --- a/watcher/tests/cmd/test_decision_engine.py +++ b/watcher/tests/cmd/test_decision_engine.py @@ -15,8 +15,8 @@ # limitations under the License. import types +from unittest import mock -import mock from oslo_config import cfg from oslo_service import service diff --git a/watcher/tests/common/loader/test_loader.py b/watcher/tests/common/loader/test_loader.py index 7abf0c9b5..9ad97836d 100644 --- a/watcher/tests/common/loader/test_loader.py +++ b/watcher/tests/common/loader/test_loader.py @@ -14,7 +14,7 @@ # 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 stevedore import driver as drivermanager diff --git a/watcher/tests/common/test_cinder_helper.py b/watcher/tests/common/test_cinder_helper.py index 6a8e632d1..be99e09f2 100644 --- a/watcher/tests/common/test_cinder_helper.py +++ b/watcher/tests/common/test_cinder_helper.py @@ -13,8 +13,8 @@ # limitations under the License. # -import mock import time +from unittest import mock from cinderclient import exceptions as cinder_exception diff --git a/watcher/tests/common/test_clients.py b/watcher/tests/common/test_clients.py index 2bf496127..00c48ed66 100755 --- a/watcher/tests/common/test_clients.py +++ b/watcher/tests/common/test_clients.py @@ -12,6 +12,8 @@ from ceilometerclient import client as ceclient import ceilometerclient.v2.client as ceclient_v2 +from unittest import mock + from cinderclient import client as ciclient from cinderclient.v3 import client as ciclient_v3 from glanceclient import client as glclient @@ -21,7 +23,6 @@ from ironicclient import client as irclient from ironicclient.v1 import client as irclient_v1 from keystoneauth1 import adapter as ka_adapter from keystoneauth1 import loading as ka_loading -import mock from monascaclient import client as monclient from monascaclient.v2_0 import client as monclient_v2 from neutronclient.neutron import client as netclient diff --git a/watcher/tests/common/test_ironic_helper.py b/watcher/tests/common/test_ironic_helper.py index d51cc285e..7aab69b78 100644 --- a/watcher/tests/common/test_ironic_helper.py +++ b/watcher/tests/common/test_ironic_helper.py @@ -17,7 +17,7 @@ # limitations under the License. # -import mock +from unittest import mock from watcher.common import clients from watcher.common import exception diff --git a/watcher/tests/common/test_nova_helper.py b/watcher/tests/common/test_nova_helper.py index 3ce2ac3bc..118698ec8 100644 --- a/watcher/tests/common/test_nova_helper.py +++ b/watcher/tests/common/test_nova_helper.py @@ -18,10 +18,10 @@ # import time +from unittest import mock from novaclient import api_versions -import mock import glanceclient.exc as glexceptions import novaclient.exceptions as nvexceptions diff --git a/watcher/tests/common/test_placement_helper.py b/watcher/tests/common/test_placement_helper.py index fc2de290b..00e906d49 100644 --- a/watcher/tests/common/test_placement_helper.py +++ b/watcher/tests/common/test_placement_helper.py @@ -11,7 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import mock +from unittest import mock from watcher.common import placement_helper from watcher.tests import base diff --git a/watcher/tests/common/test_service.py b/watcher/tests/common/test_service.py index 530b6e445..bce8353ca 100644 --- a/watcher/tests/common/test_service.py +++ b/watcher/tests/common/test_service.py @@ -15,7 +15,7 @@ # limitations under the License. -import mock +from unittest import mock from oslo_config import cfg diff --git a/watcher/tests/conf/test_list_opts.py b/watcher/tests/conf/test_list_opts.py index 192d9a57c..77bf44109 100755 --- a/watcher/tests/conf/test_list_opts.py +++ b/watcher/tests/conf/test_list_opts.py @@ -15,7 +15,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 stevedore import extension diff --git a/watcher/tests/db/test_purge.py b/watcher/tests/db/test_purge.py index beecde3ea..5d7698fe5 100644 --- a/watcher/tests/db/test_purge.py +++ b/watcher/tests/db/test_purge.py @@ -14,10 +14,11 @@ # See the License for the specific language governing permissions and # limitations under the License. +from unittest import mock + from oslo_utils import uuidutils import freezegun -import mock from watcher.common import context as watcher_context from watcher.common import utils diff --git a/watcher/tests/decision_engine/audit/test_audit_handlers.py b/watcher/tests/decision_engine/audit/test_audit_handlers.py index bfcea201d..d9f67532d 100644 --- a/watcher/tests/decision_engine/audit/test_audit_handlers.py +++ b/watcher/tests/decision_engine/audit/test_audit_handlers.py @@ -15,8 +15,8 @@ # limitations under the License. import datetime +from unittest import mock -import mock from oslo_config import cfg from oslo_utils import uuidutils diff --git a/watcher/tests/decision_engine/cluster/test_cinder_cdmc.py b/watcher/tests/decision_engine/cluster/test_cinder_cdmc.py index 3d197e066..0d9a75324 100644 --- a/watcher/tests/decision_engine/cluster/test_cinder_cdmc.py +++ b/watcher/tests/decision_engine/cluster/test_cinder_cdmc.py @@ -11,7 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import mock +from unittest import mock from watcher.common import cinder_helper from watcher.common import exception diff --git a/watcher/tests/decision_engine/cluster/test_cluster_data_model_collector.py b/watcher/tests/decision_engine/cluster/test_cluster_data_model_collector.py index 7b2ad3302..760852ab2 100644 --- a/watcher/tests/decision_engine/cluster/test_cluster_data_model_collector.py +++ b/watcher/tests/decision_engine/cluster/test_cluster_data_model_collector.py @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import mock +from unittest import mock from watcher.decision_engine.model.collector import base from watcher.decision_engine.model import model_root diff --git a/watcher/tests/decision_engine/cluster/test_nova_cdmc.py b/watcher/tests/decision_engine/cluster/test_nova_cdmc.py index 5e7b78320..749e1c068 100644 --- a/watcher/tests/decision_engine/cluster/test_nova_cdmc.py +++ b/watcher/tests/decision_engine/cluster/test_nova_cdmc.py @@ -16,8 +16,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -import mock import os_resource_classes as orc +from unittest import mock from watcher.common import nova_helper from watcher.common import placement_helper diff --git a/watcher/tests/decision_engine/datasources/grafana_translators/test_base.py b/watcher/tests/decision_engine/datasources/grafana_translators/test_base.py index aab1425f9..5393402ba 100644 --- a/watcher/tests/decision_engine/datasources/grafana_translators/test_base.py +++ b/watcher/tests/decision_engine/datasources/grafana_translators/test_base.py @@ -16,7 +16,7 @@ # 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 oslo_log import log diff --git a/watcher/tests/decision_engine/datasources/grafana_translators/test_influxdb.py b/watcher/tests/decision_engine/datasources/grafana_translators/test_influxdb.py index 6153be596..204387804 100644 --- a/watcher/tests/decision_engine/datasources/grafana_translators/test_influxdb.py +++ b/watcher/tests/decision_engine/datasources/grafana_translators/test_influxdb.py @@ -17,7 +17,7 @@ # limitations under the License. import copy -import mock +from unittest import mock from oslo_config import cfg from oslo_log import log diff --git a/watcher/tests/decision_engine/datasources/test_base.py b/watcher/tests/decision_engine/datasources/test_base.py index ac73c42a6..8254fd6e4 100644 --- a/watcher/tests/decision_engine/datasources/test_base.py +++ b/watcher/tests/decision_engine/datasources/test_base.py @@ -16,7 +16,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 watcher.decision_engine.datasources import base as datasource diff --git a/watcher/tests/decision_engine/datasources/test_ceilometer_helper.py b/watcher/tests/decision_engine/datasources/test_ceilometer_helper.py index 3d3184d4f..53f475868 100644 --- a/watcher/tests/decision_engine/datasources/test_ceilometer_helper.py +++ b/watcher/tests/decision_engine/datasources/test_ceilometer_helper.py @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import mock +from unittest import mock from watcher.common import clients from watcher.common import exception diff --git a/watcher/tests/decision_engine/datasources/test_gnocchi_helper.py b/watcher/tests/decision_engine/datasources/test_gnocchi_helper.py index f69678f4a..bab3b5303 100644 --- a/watcher/tests/decision_engine/datasources/test_gnocchi_helper.py +++ b/watcher/tests/decision_engine/datasources/test_gnocchi_helper.py @@ -14,7 +14,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 watcher.common import clients diff --git a/watcher/tests/decision_engine/datasources/test_grafana_helper.py b/watcher/tests/decision_engine/datasources/test_grafana_helper.py index a0204ded2..1e716d742 100644 --- a/watcher/tests/decision_engine/datasources/test_grafana_helper.py +++ b/watcher/tests/decision_engine/datasources/test_grafana_helper.py @@ -16,7 +16,7 @@ # 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 oslo_log import log diff --git a/watcher/tests/decision_engine/datasources/test_manager.py b/watcher/tests/decision_engine/datasources/test_manager.py index 003d827c7..513616d32 100644 --- a/watcher/tests/decision_engine/datasources/test_manager.py +++ b/watcher/tests/decision_engine/datasources/test_manager.py @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import mock +from unittest import mock from mock import MagicMock diff --git a/watcher/tests/decision_engine/datasources/test_monasca_helper.py b/watcher/tests/decision_engine/datasources/test_monasca_helper.py index 52b6166f3..a4f45f879 100644 --- a/watcher/tests/decision_engine/datasources/test_monasca_helper.py +++ b/watcher/tests/decision_engine/datasources/test_monasca_helper.py @@ -14,7 +14,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 watcher.common import clients diff --git a/watcher/tests/decision_engine/loading/test_collector_loader.py b/watcher/tests/decision_engine/loading/test_collector_loader.py index 049c34801..403ebad92 100644 --- a/watcher/tests/decision_engine/loading/test_collector_loader.py +++ b/watcher/tests/decision_engine/loading/test_collector_loader.py @@ -14,9 +14,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import mock from stevedore import driver as drivermanager from stevedore import extension as stevedore_extension +from unittest import mock from watcher.common import clients from watcher.common import exception diff --git a/watcher/tests/decision_engine/loading/test_default_strategy_loader.py b/watcher/tests/decision_engine/loading/test_default_strategy_loader.py index 5bb3c58f5..e544303b3 100644 --- a/watcher/tests/decision_engine/loading/test_default_strategy_loader.py +++ b/watcher/tests/decision_engine/loading/test_default_strategy_loader.py @@ -14,8 +14,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -import mock from stevedore import extension +from unittest import mock from watcher.common import exception from watcher.decision_engine.loading import default as default_loading diff --git a/watcher/tests/decision_engine/loading/test_goal_loader.py b/watcher/tests/decision_engine/loading/test_goal_loader.py index 13ab6185e..d188aeaac 100644 --- a/watcher/tests/decision_engine/loading/test_goal_loader.py +++ b/watcher/tests/decision_engine/loading/test_goal_loader.py @@ -14,8 +14,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -import mock from stevedore import extension +from unittest import mock from watcher.common import exception from watcher.decision_engine.goal import goals diff --git a/watcher/tests/decision_engine/messaging/test_audit_endpoint.py b/watcher/tests/decision_engine/messaging/test_audit_endpoint.py index 2a72cbad6..756b451f2 100644 --- a/watcher/tests/decision_engine/messaging/test_audit_endpoint.py +++ b/watcher/tests/decision_engine/messaging/test_audit_endpoint.py @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import mock +from unittest import mock from watcher.decision_engine.audit import continuous as continuous_handler from watcher.decision_engine.audit import oneshot as oneshot_handler diff --git a/watcher/tests/decision_engine/messaging/test_data_model_endpoint.py b/watcher/tests/decision_engine/messaging/test_data_model_endpoint.py index fda6b259a..b0e375b4e 100644 --- a/watcher/tests/decision_engine/messaging/test_data_model_endpoint.py +++ b/watcher/tests/decision_engine/messaging/test_data_model_endpoint.py @@ -13,8 +13,9 @@ # implied. # See the License for the specific language governing permissions and # limitations under the License. -import mock + import unittest +from unittest import mock from watcher.common import exception from watcher.common import utils diff --git a/watcher/tests/decision_engine/model/faker_cluster_and_metrics.py b/watcher/tests/decision_engine/model/faker_cluster_and_metrics.py index 0afa43012..2335f85ab 100644 --- a/watcher/tests/decision_engine/model/faker_cluster_and_metrics.py +++ b/watcher/tests/decision_engine/model/faker_cluster_and_metrics.py @@ -18,8 +18,8 @@ # limitations under the License. import os +from unittest import mock -import mock from watcher.decision_engine.model.collector import base from watcher.decision_engine.model import model_root as modelroot diff --git a/watcher/tests/decision_engine/model/faker_cluster_state.py b/watcher/tests/decision_engine/model/faker_cluster_state.py index ac1602645..f184ad6f4 100644 --- a/watcher/tests/decision_engine/model/faker_cluster_state.py +++ b/watcher/tests/decision_engine/model/faker_cluster_state.py @@ -17,8 +17,8 @@ # limitations under the License. import os +from unittest import mock -import mock from watcher.common import utils from watcher.decision_engine.model.collector import base diff --git a/watcher/tests/decision_engine/model/notification/test_cinder_notifications.py b/watcher/tests/decision_engine/model/notification/test_cinder_notifications.py index f7956e081..439ff43d8 100644 --- a/watcher/tests/decision_engine/model/notification/test_cinder_notifications.py +++ b/watcher/tests/decision_engine/model/notification/test_cinder_notifications.py @@ -16,8 +16,8 @@ import datetime import os +from unittest import mock -import mock from oslo_serialization import jsonutils from watcher.common import cinder_helper diff --git a/watcher/tests/decision_engine/model/notification/test_notifications.py b/watcher/tests/decision_engine/model/notification/test_notifications.py index 9e2e6fab8..2be861b92 100644 --- a/watcher/tests/decision_engine/model/notification/test_notifications.py +++ b/watcher/tests/decision_engine/model/notification/test_notifications.py @@ -17,8 +17,8 @@ # limitations under the License. import os +from unittest import mock -import mock from oslo_serialization import jsonutils from watcher.common import context diff --git a/watcher/tests/decision_engine/model/notification/test_nova_notifications.py b/watcher/tests/decision_engine/model/notification/test_nova_notifications.py index 3de95c3f4..d5b9f6e38 100644 --- a/watcher/tests/decision_engine/model/notification/test_nova_notifications.py +++ b/watcher/tests/decision_engine/model/notification/test_nova_notifications.py @@ -18,8 +18,8 @@ import os import os_resource_classes as orc +from unittest import mock -import mock from oslo_serialization import jsonutils from watcher.common import context diff --git a/watcher/tests/decision_engine/model/test_model.py b/watcher/tests/decision_engine/model/test_model.py index 557994bd8..a6c651668 100644 --- a/watcher/tests/decision_engine/model/test_model.py +++ b/watcher/tests/decision_engine/model/test_model.py @@ -16,8 +16,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -import mock import os +from unittest import mock from oslo_utils import uuidutils diff --git a/watcher/tests/decision_engine/planner/test_node_resource_consolidation.py b/watcher/tests/decision_engine/planner/test_node_resource_consolidation.py index 637bacea2..e0066c306 100644 --- a/watcher/tests/decision_engine/planner/test_node_resource_consolidation.py +++ b/watcher/tests/decision_engine/planner/test_node_resource_consolidation.py @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import mock +from unittest import mock from watcher.common import exception from watcher.common import utils diff --git a/watcher/tests/decision_engine/planner/test_weight_planner.py b/watcher/tests/decision_engine/planner/test_weight_planner.py index 3c9cc48a2..fcc26e35e 100644 --- a/watcher/tests/decision_engine/planner/test_weight_planner.py +++ b/watcher/tests/decision_engine/planner/test_weight_planner.py @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import mock +from unittest import mock from watcher.common import nova_helper from watcher.common import utils diff --git a/watcher/tests/decision_engine/planner/test_workload_stabilization_planner.py b/watcher/tests/decision_engine/planner/test_workload_stabilization_planner.py index 4956fef6d..305e85feb 100644 --- a/watcher/tests/decision_engine/planner/test_workload_stabilization_planner.py +++ b/watcher/tests/decision_engine/planner/test_workload_stabilization_planner.py @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import mock +from unittest import mock from watcher.common import exception from watcher.common import nova_helper diff --git a/watcher/tests/decision_engine/scope/test_baremetal.py b/watcher/tests/decision_engine/scope/test_baremetal.py index 9522cbc9f..5898c0ed6 100644 --- a/watcher/tests/decision_engine/scope/test_baremetal.py +++ b/watcher/tests/decision_engine/scope/test_baremetal.py @@ -15,7 +15,7 @@ # limitations under the License. # -import mock +from unittest import mock from watcher.decision_engine.scope import baremetal from watcher.tests import base diff --git a/watcher/tests/decision_engine/scope/test_compute.py b/watcher/tests/decision_engine/scope/test_compute.py index b4297e7a3..01faba806 100644 --- a/watcher/tests/decision_engine/scope/test_compute.py +++ b/watcher/tests/decision_engine/scope/test_compute.py @@ -16,7 +16,7 @@ # from jsonschema import validators -import mock +from unittest import mock from watcher.api.controllers.v1 import audit_template from watcher.common import exception diff --git a/watcher/tests/decision_engine/scope/test_storage.py b/watcher/tests/decision_engine/scope/test_storage.py index e6caa0760..da7920adb 100644 --- a/watcher/tests/decision_engine/scope/test_storage.py +++ b/watcher/tests/decision_engine/scope/test_storage.py @@ -15,7 +15,7 @@ # limitations under the License. # -import mock +from unittest import mock from watcher.common import cinder_helper from watcher.common import exception diff --git a/watcher/tests/decision_engine/solution/test_default_solution.py b/watcher/tests/decision_engine/solution/test_default_solution.py index 5b1492989..fd526dbe0 100644 --- a/watcher/tests/decision_engine/solution/test_default_solution.py +++ b/watcher/tests/decision_engine/solution/test_default_solution.py @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import mock +from unittest import mock from watcher.decision_engine.solution import default from watcher.decision_engine.strategy import strategies diff --git a/watcher/tests/decision_engine/strategy/context/test_strategy_context.py b/watcher/tests/decision_engine/strategy/context/test_strategy_context.py index 74bdf1b1d..89ac57830 100644 --- a/watcher/tests/decision_engine/strategy/context/test_strategy_context.py +++ b/watcher/tests/decision_engine/strategy/context/test_strategy_context.py @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import mock +from unittest import mock from watcher.common import utils from watcher.decision_engine.model.collector import manager diff --git a/watcher/tests/decision_engine/strategy/selector/test_strategy_selector.py b/watcher/tests/decision_engine/strategy/selector/test_strategy_selector.py index f521a91d4..711db0db3 100644 --- a/watcher/tests/decision_engine/strategy/selector/test_strategy_selector.py +++ b/watcher/tests/decision_engine/strategy/selector/test_strategy_selector.py @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import mock +from unittest import mock from watcher.common import exception from watcher.decision_engine.loading import default as default_loader diff --git a/watcher/tests/decision_engine/strategy/strategies/test_actuator.py b/watcher/tests/decision_engine/strategy/strategies/test_actuator.py index 64d517685..6734436ad 100644 --- a/watcher/tests/decision_engine/strategy/strategies/test_actuator.py +++ b/watcher/tests/decision_engine/strategy/strategies/test_actuator.py @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import mock +from unittest import mock from watcher.common import utils from watcher.decision_engine.strategy import strategies diff --git a/watcher/tests/decision_engine/strategy/strategies/test_base.py b/watcher/tests/decision_engine/strategy/strategies/test_base.py index b4bce31b0..6ad190f41 100644 --- a/watcher/tests/decision_engine/strategy/strategies/test_base.py +++ b/watcher/tests/decision_engine/strategy/strategies/test_base.py @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import mock +from unittest import mock from watcher.common import exception from watcher.decision_engine.datasources import manager diff --git a/watcher/tests/decision_engine/strategy/strategies/test_basic_consolidation.py b/watcher/tests/decision_engine/strategy/strategies/test_basic_consolidation.py index 82360e1fd..7b3401f74 100644 --- a/watcher/tests/decision_engine/strategy/strategies/test_basic_consolidation.py +++ b/watcher/tests/decision_engine/strategy/strategies/test_basic_consolidation.py @@ -18,7 +18,7 @@ # import collections import copy -import mock +from unittest import mock from watcher.applier.loading import default from watcher.common import clients diff --git a/watcher/tests/decision_engine/strategy/strategies/test_dummy_strategy.py b/watcher/tests/decision_engine/strategy/strategies/test_dummy_strategy.py index 00214e85e..549a03202 100644 --- a/watcher/tests/decision_engine/strategy/strategies/test_dummy_strategy.py +++ b/watcher/tests/decision_engine/strategy/strategies/test_dummy_strategy.py @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import mock +from unittest import mock from watcher.applier.loading import default from watcher.common import utils diff --git a/watcher/tests/decision_engine/strategy/strategies/test_dummy_with_scorer.py b/watcher/tests/decision_engine/strategy/strategies/test_dummy_with_scorer.py index 590ca4f11..0886207b9 100644 --- a/watcher/tests/decision_engine/strategy/strategies/test_dummy_with_scorer.py +++ b/watcher/tests/decision_engine/strategy/strategies/test_dummy_with_scorer.py @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import mock +from unittest import mock from watcher.applier.loading import default from watcher.common import utils diff --git a/watcher/tests/decision_engine/strategy/strategies/test_host_maintenance.py b/watcher/tests/decision_engine/strategy/strategies/test_host_maintenance.py index 51daec37f..d941f24f7 100755 --- a/watcher/tests/decision_engine/strategy/strategies/test_host_maintenance.py +++ b/watcher/tests/decision_engine/strategy/strategies/test_host_maintenance.py @@ -17,7 +17,7 @@ # limitations under the License. # -import mock +from unittest import mock from watcher.common import exception from watcher.decision_engine.model import element diff --git a/watcher/tests/decision_engine/strategy/strategies/test_node_resource_consolidation.py b/watcher/tests/decision_engine/strategy/strategies/test_node_resource_consolidation.py index 7c598db6c..aebaba9b3 100644 --- a/watcher/tests/decision_engine/strategy/strategies/test_node_resource_consolidation.py +++ b/watcher/tests/decision_engine/strategy/strategies/test_node_resource_consolidation.py @@ -15,7 +15,7 @@ # limitations under the License. # -import mock +from unittest import mock from watcher.common import exception from watcher.decision_engine.model import element diff --git a/watcher/tests/decision_engine/strategy/strategies/test_noisy_neighbor.py b/watcher/tests/decision_engine/strategy/strategies/test_noisy_neighbor.py index 929c7f506..6aa2f90ff 100644 --- a/watcher/tests/decision_engine/strategy/strategies/test_noisy_neighbor.py +++ b/watcher/tests/decision_engine/strategy/strategies/test_noisy_neighbor.py @@ -17,7 +17,7 @@ # limitations under the License. import collections -import mock +from unittest import mock from watcher.applier.loading import default from watcher.common import utils diff --git a/watcher/tests/decision_engine/strategy/strategies/test_outlet_temp_control.py b/watcher/tests/decision_engine/strategy/strategies/test_outlet_temp_control.py index 93d958d8d..50e92c1b0 100644 --- a/watcher/tests/decision_engine/strategy/strategies/test_outlet_temp_control.py +++ b/watcher/tests/decision_engine/strategy/strategies/test_outlet_temp_control.py @@ -17,7 +17,7 @@ # limitations under the License. # import collections -import mock +from unittest import mock from watcher.applier.loading import default from watcher.common import utils diff --git a/watcher/tests/decision_engine/strategy/strategies/test_saving_energy.py b/watcher/tests/decision_engine/strategy/strategies/test_saving_energy.py index 39c547976..c8082d154 100644 --- a/watcher/tests/decision_engine/strategy/strategies/test_saving_energy.py +++ b/watcher/tests/decision_engine/strategy/strategies/test_saving_energy.py @@ -15,7 +15,7 @@ # limitations under the License. # -import mock +from unittest import mock from watcher.common import clients from watcher.common import utils diff --git a/watcher/tests/decision_engine/strategy/strategies/test_storage_capacity_balance.py b/watcher/tests/decision_engine/strategy/strategies/test_storage_capacity_balance.py index d3d28778b..8c354ccdc 100644 --- a/watcher/tests/decision_engine/strategy/strategies/test_storage_capacity_balance.py +++ b/watcher/tests/decision_engine/strategy/strategies/test_storage_capacity_balance.py @@ -17,7 +17,7 @@ # limitations under the License. # -import mock +from unittest import mock from watcher.common import cinder_helper diff --git a/watcher/tests/decision_engine/strategy/strategies/test_strategy_endpoint.py b/watcher/tests/decision_engine/strategy/strategies/test_strategy_endpoint.py index e460ce4dd..26a7d920f 100644 --- a/watcher/tests/decision_engine/strategy/strategies/test_strategy_endpoint.py +++ b/watcher/tests/decision_engine/strategy/strategies/test_strategy_endpoint.py @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import mock +from unittest import mock from watcher.decision_engine.strategy.strategies import base as strategy_base from watcher.tests import base diff --git a/watcher/tests/decision_engine/strategy/strategies/test_uniform_airflow.py b/watcher/tests/decision_engine/strategy/strategies/test_uniform_airflow.py index 91387ade1..f9ec771fa 100644 --- a/watcher/tests/decision_engine/strategy/strategies/test_uniform_airflow.py +++ b/watcher/tests/decision_engine/strategy/strategies/test_uniform_airflow.py @@ -17,7 +17,7 @@ # limitations under the License. # import collections -import mock +from unittest import mock from watcher.applier.loading import default from watcher.common import utils diff --git a/watcher/tests/decision_engine/strategy/strategies/test_vm_workload_consolidation.py b/watcher/tests/decision_engine/strategy/strategies/test_vm_workload_consolidation.py index d2dccff9e..616815a1c 100644 --- a/watcher/tests/decision_engine/strategy/strategies/test_vm_workload_consolidation.py +++ b/watcher/tests/decision_engine/strategy/strategies/test_vm_workload_consolidation.py @@ -18,7 +18,7 @@ # limitations under the License. # -import mock +from unittest import mock from watcher.decision_engine.model import element from watcher.decision_engine.solution.base import BaseSolution diff --git a/watcher/tests/decision_engine/strategy/strategies/test_workload_balance.py b/watcher/tests/decision_engine/strategy/strategies/test_workload_balance.py index ffe9c2afb..43943bc5c 100644 --- a/watcher/tests/decision_engine/strategy/strategies/test_workload_balance.py +++ b/watcher/tests/decision_engine/strategy/strategies/test_workload_balance.py @@ -17,7 +17,7 @@ # limitations under the License. # import collections -import mock +from unittest import mock from watcher.applier.loading import default from watcher.common import utils diff --git a/watcher/tests/decision_engine/strategy/strategies/test_workload_stabilization.py b/watcher/tests/decision_engine/strategy/strategies/test_workload_stabilization.py index 167b0e7d4..0fd73b882 100644 --- a/watcher/tests/decision_engine/strategy/strategies/test_workload_stabilization.py +++ b/watcher/tests/decision_engine/strategy/strategies/test_workload_stabilization.py @@ -17,7 +17,7 @@ # limitations under the License. # -import mock +from unittest import mock from watcher.common import clients from watcher.common import utils diff --git a/watcher/tests/decision_engine/strategy/strategies/test_zone_migration.py b/watcher/tests/decision_engine/strategy/strategies/test_zone_migration.py index 71b1e4920..6a9b820a1 100644 --- a/watcher/tests/decision_engine/strategy/strategies/test_zone_migration.py +++ b/watcher/tests/decision_engine/strategy/strategies/test_zone_migration.py @@ -12,7 +12,7 @@ # limitations under the License. import collections -import mock +from unittest import mock import cinderclient import novaclient diff --git a/watcher/tests/decision_engine/test_gmr.py b/watcher/tests/decision_engine/test_gmr.py index d686a6deb..3ffbc28ba 100644 --- a/watcher/tests/decision_engine/test_gmr.py +++ b/watcher/tests/decision_engine/test_gmr.py @@ -16,7 +16,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import mock +from unittest import mock from watcher.decision_engine import gmr from watcher.decision_engine.model.collector import manager diff --git a/watcher/tests/decision_engine/test_rpcapi.py b/watcher/tests/decision_engine/test_rpcapi.py index 163035764..53c7cf5a6 100644 --- a/watcher/tests/decision_engine/test_rpcapi.py +++ b/watcher/tests/decision_engine/test_rpcapi.py @@ -14,7 +14,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -import mock +from unittest import mock + import oslo_messaging as om from watcher.common import exception from watcher.common import utils diff --git a/watcher/tests/decision_engine/test_scheduling.py b/watcher/tests/decision_engine/test_scheduling.py index 278aa28a2..d9b80b700 100644 --- a/watcher/tests/decision_engine/test_scheduling.py +++ b/watcher/tests/decision_engine/test_scheduling.py @@ -19,7 +19,7 @@ from apscheduler.schedulers import background from apscheduler.triggers import interval as interval_trigger import eventlet -import mock +from unittest import mock from oslo_config import cfg from oslo_utils import uuidutils diff --git a/watcher/tests/decision_engine/test_sync.py b/watcher/tests/decision_engine/test_sync.py index 490e256c2..df397919e 100644 --- a/watcher/tests/decision_engine/test_sync.py +++ b/watcher/tests/decision_engine/test_sync.py @@ -14,7 +14,7 @@ # See the 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/watcher/tests/fakes.py b/watcher/tests/fakes.py index 012b8a198..e9f125699 100644 --- a/watcher/tests/fakes.py +++ b/watcher/tests/fakes.py @@ -10,8 +10,8 @@ # License for the specific language governing permissions and limitations # under the License. -import mock import requests +from unittest import mock fakeAuthTokenHeaders = {'X-User-Id': u'773a902f022949619b5c2f32cd89d419', 'X-Roles': u'admin, ResellerAdmin, _member_', diff --git a/watcher/tests/notifications/test_action_notification.py b/watcher/tests/notifications/test_action_notification.py index 0c8675bcc..3a65da899 100644 --- a/watcher/tests/notifications/test_action_notification.py +++ b/watcher/tests/notifications/test_action_notification.py @@ -13,7 +13,8 @@ # under the License. import freezegun -import mock +from unittest import mock + import oslo_messaging as om from watcher.common import exception diff --git a/watcher/tests/notifications/test_action_plan_notification.py b/watcher/tests/notifications/test_action_plan_notification.py index 93f70904e..91d19d021 100644 --- a/watcher/tests/notifications/test_action_plan_notification.py +++ b/watcher/tests/notifications/test_action_plan_notification.py @@ -13,7 +13,8 @@ # under the License. import freezegun -import mock +from unittest import mock + import oslo_messaging as om from watcher.common import exception diff --git a/watcher/tests/notifications/test_audit_notification.py b/watcher/tests/notifications/test_audit_notification.py index f7eb2c097..6e060655f 100644 --- a/watcher/tests/notifications/test_audit_notification.py +++ b/watcher/tests/notifications/test_audit_notification.py @@ -13,7 +13,8 @@ # under the License. import freezegun -import mock +from unittest import mock + import oslo_messaging as om from watcher.common import exception diff --git a/watcher/tests/notifications/test_notification.py b/watcher/tests/notifications/test_notification.py index 30b809193..f55a6d478 100644 --- a/watcher/tests/notifications/test_notification.py +++ b/watcher/tests/notifications/test_notification.py @@ -13,8 +13,8 @@ # under the License. import collections +from unittest import mock -import mock from oslo_versionedobjects import fixture from watcher.common import exception diff --git a/watcher/tests/notifications/test_service_notifications.py b/watcher/tests/notifications/test_service_notifications.py index 538fed081..9298a93d2 100644 --- a/watcher/tests/notifications/test_service_notifications.py +++ b/watcher/tests/notifications/test_service_notifications.py @@ -15,9 +15,9 @@ # limitations under the License. import datetime +from unittest import mock import freezegun -import mock import oslo_messaging as om from watcher.common import rpc diff --git a/watcher/tests/objects/test_action.py b/watcher/tests/objects/test_action.py index 1b27dda60..462588d86 100644 --- a/watcher/tests/objects/test_action.py +++ b/watcher/tests/objects/test_action.py @@ -14,9 +14,9 @@ # under the License. import datetime +from unittest import mock import iso8601 -import mock from watcher.common import exception from watcher.common import utils as c_utils diff --git a/watcher/tests/objects/test_action_description.py b/watcher/tests/objects/test_action_description.py index 91dba2158..966808684 100644 --- a/watcher/tests/objects/test_action_description.py +++ b/watcher/tests/objects/test_action_description.py @@ -15,9 +15,9 @@ # under the License. import datetime +from unittest import mock import iso8601 -import mock from watcher.db.sqlalchemy import api as db_api from watcher import objects diff --git a/watcher/tests/objects/test_action_plan.py b/watcher/tests/objects/test_action_plan.py index b807e0bfe..a25e8720d 100644 --- a/watcher/tests/objects/test_action_plan.py +++ b/watcher/tests/objects/test_action_plan.py @@ -14,9 +14,9 @@ # under the License. import datetime +from unittest import mock import iso8601 -import mock from watcher.common import exception from watcher.common import utils as common_utils diff --git a/watcher/tests/objects/test_audit.py b/watcher/tests/objects/test_audit.py index 4537802d0..d16dbb3e4 100644 --- a/watcher/tests/objects/test_audit.py +++ b/watcher/tests/objects/test_audit.py @@ -14,9 +14,9 @@ # under the License. import datetime +from unittest import mock import iso8601 -import mock from watcher.common import exception from watcher.common import rpc diff --git a/watcher/tests/objects/test_audit_template.py b/watcher/tests/objects/test_audit_template.py index 3b340016d..8d62cef11 100644 --- a/watcher/tests/objects/test_audit_template.py +++ b/watcher/tests/objects/test_audit_template.py @@ -14,9 +14,9 @@ # under the License. import datetime +from unittest import mock import iso8601 -import mock from watcher.common import exception from watcher.common import utils as w_utils diff --git a/watcher/tests/objects/test_efficacy_indicator.py b/watcher/tests/objects/test_efficacy_indicator.py index 1e5bfb41c..3d019fd99 100644 --- a/watcher/tests/objects/test_efficacy_indicator.py +++ b/watcher/tests/objects/test_efficacy_indicator.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from watcher.common import exception # from watcher.common import utils as w_utils from watcher import objects diff --git a/watcher/tests/objects/test_goal.py b/watcher/tests/objects/test_goal.py index fc3914f6b..23297483f 100644 --- a/watcher/tests/objects/test_goal.py +++ b/watcher/tests/objects/test_goal.py @@ -14,9 +14,9 @@ # under the License. import datetime +from unittest import mock import iso8601 -import mock from watcher.db.sqlalchemy import api as db_api from watcher import objects diff --git a/watcher/tests/objects/test_objects.py b/watcher/tests/objects/test_objects.py index 69bc9a236..b40e33a44 100644 --- a/watcher/tests/objects/test_objects.py +++ b/watcher/tests/objects/test_objects.py @@ -16,8 +16,8 @@ import contextlib import datetime import gettext import iso8601 +from unittest import mock -import mock from oslo_versionedobjects import base as object_base from oslo_versionedobjects import exception as object_exception from oslo_versionedobjects import fixture as object_fixture diff --git a/watcher/tests/objects/test_scoring_engine.py b/watcher/tests/objects/test_scoring_engine.py index 35730b600..fbe5da344 100644 --- a/watcher/tests/objects/test_scoring_engine.py +++ b/watcher/tests/objects/test_scoring_engine.py @@ -14,9 +14,9 @@ # under the License. import datetime +from unittest import mock import iso8601 -import mock from watcher.db.sqlalchemy import api as db_api from watcher import objects diff --git a/watcher/tests/objects/test_service.py b/watcher/tests/objects/test_service.py index cdfd99040..87abda369 100644 --- a/watcher/tests/objects/test_service.py +++ b/watcher/tests/objects/test_service.py @@ -14,9 +14,9 @@ # under the License. import datetime +from unittest import mock import iso8601 -import mock from watcher.db.sqlalchemy import api as db_api from watcher import objects diff --git a/watcher/tests/objects/test_strategy.py b/watcher/tests/objects/test_strategy.py index 3d1a47dc5..c2a9f1bec 100644 --- a/watcher/tests/objects/test_strategy.py +++ b/watcher/tests/objects/test_strategy.py @@ -14,7 +14,7 @@ # under the License. -import mock +from unittest import mock from watcher.common import exception from watcher.db.sqlalchemy import api as db_api diff --git a/watcher/tests/test_threading.py b/watcher/tests/test_threading.py index 5f9f9b465..11507d217 100644 --- a/watcher/tests/test_threading.py +++ b/watcher/tests/test_threading.py @@ -17,7 +17,7 @@ # limitations under the License. import futurist -import mock +from unittest import mock from watcher.decision_engine import threading from watcher.tests import base