From 92c15fa38a126b5fde294420cf84dbd713dcfd50 Mon Sep 17 00:00:00 2001 From: jacky06 Date: Tue, 7 Apr 2020 22:21:43 +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. Change-Id: Idac937dd704ef11dfc33e197f7539e3f7a5feb92 --- lower-constraints.txt | 1 - test-requirements.txt | 1 - watcherclient/tests/unit/common/test_api_versioning.py | 2 +- watcherclient/tests/unit/test_client.py | 2 +- watcherclient/tests/unit/test_utils.py | 2 +- watcherclient/tests/unit/utils.py | 2 +- watcherclient/tests/unit/v1/base.py | 2 +- watcherclient/tests/unit/v1/test_action_plan.py | 2 +- watcherclient/tests/unit/v1/test_action_plan_shell.py | 5 +++-- watcherclient/tests/unit/v1/test_action_shell.py | 3 ++- watcherclient/tests/unit/v1/test_audit_shell.py | 3 ++- watcherclient/tests/unit/v1/test_audit_template_shell.py | 3 ++- watcherclient/tests/unit/v1/test_data_model_shell.py | 4 +++- watcherclient/tests/unit/v1/test_goal_shell.py | 3 ++- watcherclient/tests/unit/v1/test_scoring_engine_shell.py | 3 ++- watcherclient/tests/unit/v1/test_service_shell.py | 3 ++- watcherclient/tests/unit/v1/test_strategy_shell.py | 4 ++-- 17 files changed, 26 insertions(+), 19 deletions(-) diff --git a/lower-constraints.txt b/lower-constraints.txt index f275283..cb3b34d 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -33,7 +33,6 @@ keystoneauth1==3.4.0 linecache2==1.0.0 MarkupSafe==1.0 mccabe==0.2.1 -mock==2.0.0 monotonic==1.4 mox3==0.20.0 msgpack-python==0.4.0 diff --git a/test-requirements.txt b/test-requirements.txt index c76f149..fcbc123 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -5,7 +5,6 @@ coverage!=4.4,>=4.0 # Apache-2.0 fixtures>=3.0.0 # Apache-2.0/BSD hacking>=3.0,<3.1.0 # Apache-2.0 -mock>=2.0.0 # BSD oslotest>=3.2.0 # Apache-2.0 python-subunit>=1.0.0 # Apache-2.0/BSD stestr>=2.0.0 # Apache-2.0 diff --git a/watcherclient/tests/unit/common/test_api_versioning.py b/watcherclient/tests/unit/common/test_api_versioning.py index f2b9528..84a23d1 100644 --- a/watcherclient/tests/unit/common/test_api_versioning.py +++ b/watcherclient/tests/unit/common/test_api_versioning.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from watcherclient.common import api_versioning from watcherclient import exceptions diff --git a/watcherclient/tests/unit/test_client.py b/watcherclient/tests/unit/test_client.py index f1ce98c..4d12419 100644 --- a/watcherclient/tests/unit/test_client.py +++ b/watcherclient/tests/unit/test_client.py @@ -10,7 +10,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from keystoneauth1 import loading as kaloading diff --git a/watcherclient/tests/unit/test_utils.py b/watcherclient/tests/unit/test_utils.py index 2c143dd..2f7c7af 100644 --- a/watcherclient/tests/unit/test_utils.py +++ b/watcherclient/tests/unit/test_utils.py @@ -14,7 +14,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from watcherclient.common.apiclient import exceptions as exc from watcherclient.common import utils diff --git a/watcherclient/tests/unit/utils.py b/watcherclient/tests/unit/utils.py index 10aa2bf..f81a2f9 100644 --- a/watcherclient/tests/unit/utils.py +++ b/watcherclient/tests/unit/utils.py @@ -15,9 +15,9 @@ import copy import os +from unittest import mock import fixtures -import mock from oslo_utils import strutils import six import testtools diff --git a/watcherclient/tests/unit/v1/base.py b/watcherclient/tests/unit/v1/base.py index 2eed37b..ccd69c0 100644 --- a/watcherclient/tests/unit/v1/base.py +++ b/watcherclient/tests/unit/v1/base.py @@ -14,8 +14,8 @@ # limitations under the License. import shlex +from unittest import mock -import mock from osc_lib import utils as oscutils from oslo_serialization import jsonutils diff --git a/watcherclient/tests/unit/v1/test_action_plan.py b/watcherclient/tests/unit/v1/test_action_plan.py index 262e077..b8b5dcf 100644 --- a/watcherclient/tests/unit/v1/test_action_plan.py +++ b/watcherclient/tests/unit/v1/test_action_plan.py @@ -14,7 +14,7 @@ # under the License. import copy -import mock +from unittest import mock import testtools from testtools import matchers diff --git a/watcherclient/tests/unit/v1/test_action_plan_shell.py b/watcherclient/tests/unit/v1/test_action_plan_shell.py index 4574355..786b54b 100644 --- a/watcherclient/tests/unit/v1/test_action_plan_shell.py +++ b/watcherclient/tests/unit/v1/test_action_plan_shell.py @@ -14,10 +14,11 @@ # limitations under the License. import datetime -import mock -import six +from unittest import mock from oslo_utils.uuidutils import generate_uuid +import six + from watcherclient import exceptions from watcherclient import shell from watcherclient.tests.unit.v1 import base diff --git a/watcherclient/tests/unit/v1/test_action_shell.py b/watcherclient/tests/unit/v1/test_action_shell.py index fafd84b..becd6cc 100644 --- a/watcherclient/tests/unit/v1/test_action_shell.py +++ b/watcherclient/tests/unit/v1/test_action_shell.py @@ -14,7 +14,8 @@ # under the License. import datetime -import mock +from unittest import mock + import six from watcherclient import exceptions diff --git a/watcherclient/tests/unit/v1/test_audit_shell.py b/watcherclient/tests/unit/v1/test_audit_shell.py index c2d661c..95fef09 100755 --- a/watcherclient/tests/unit/v1/test_audit_shell.py +++ b/watcherclient/tests/unit/v1/test_audit_shell.py @@ -14,7 +14,8 @@ # under the License. import datetime -import mock +from unittest import mock + import six from watcherclient import shell diff --git a/watcherclient/tests/unit/v1/test_audit_template_shell.py b/watcherclient/tests/unit/v1/test_audit_template_shell.py index f1e58bb..e954a30 100644 --- a/watcherclient/tests/unit/v1/test_audit_template_shell.py +++ b/watcherclient/tests/unit/v1/test_audit_template_shell.py @@ -14,7 +14,8 @@ # under the License. import datetime -import mock +from unittest import mock + import six from watcherclient import shell diff --git a/watcherclient/tests/unit/v1/test_data_model_shell.py b/watcherclient/tests/unit/v1/test_data_model_shell.py index ad8a8c6..76c8045 100644 --- a/watcherclient/tests/unit/v1/test_data_model_shell.py +++ b/watcherclient/tests/unit/v1/test_data_model_shell.py @@ -12,7 +12,9 @@ # implied. # See the License for the specific language governing permissions and # limitations under the License. -import mock + +from unittest import mock + import six from watcherclient import shell diff --git a/watcherclient/tests/unit/v1/test_goal_shell.py b/watcherclient/tests/unit/v1/test_goal_shell.py index 363ee56..fd324d3 100644 --- a/watcherclient/tests/unit/v1/test_goal_shell.py +++ b/watcherclient/tests/unit/v1/test_goal_shell.py @@ -14,7 +14,8 @@ # limitations under the License. import datetime -import mock +from unittest import mock + import six from watcherclient import shell diff --git a/watcherclient/tests/unit/v1/test_scoring_engine_shell.py b/watcherclient/tests/unit/v1/test_scoring_engine_shell.py index 5f7ce85..64f7501 100644 --- a/watcherclient/tests/unit/v1/test_scoring_engine_shell.py +++ b/watcherclient/tests/unit/v1/test_scoring_engine_shell.py @@ -14,7 +14,8 @@ # limitations under the License. import datetime -import mock +from unittest import mock + import six from watcherclient import shell diff --git a/watcherclient/tests/unit/v1/test_service_shell.py b/watcherclient/tests/unit/v1/test_service_shell.py index 1d4ad60..bccf2ad 100644 --- a/watcherclient/tests/unit/v1/test_service_shell.py +++ b/watcherclient/tests/unit/v1/test_service_shell.py @@ -14,7 +14,8 @@ # limitations under the License. import datetime -import mock +from unittest import mock + import six from watcherclient import shell diff --git a/watcherclient/tests/unit/v1/test_strategy_shell.py b/watcherclient/tests/unit/v1/test_strategy_shell.py index 7a15687..cb7c48c 100644 --- a/watcherclient/tests/unit/v1/test_strategy_shell.py +++ b/watcherclient/tests/unit/v1/test_strategy_shell.py @@ -14,10 +14,10 @@ # limitations under the License. import datetime -import mock -import six +from unittest import mock from oslo_serialization import jsonutils +import six from watcherclient import shell from watcherclient.tests.unit.v1 import base