From 92781c975c6a6d01ae78c3573ec32c4c59b896ff Mon Sep 17 00:00:00 2001 From: Dongcan Ye Date: Thu, 2 Apr 2020 01:56:51 +0000 Subject: [PATCH] Using unittest.mock instead of mock We're only support py3 now, so using the standard library unittest.mock instead of the mock module. Change-Id: Ie827780a950cf66030ee1a688674e66ca7f3479c --- lower-constraints.txt | 1 - neutron_vpnaas/tests/functional/common/test_scenario.py | 2 +- .../tests/functional/openswan/test_openswan_driver.py | 3 ++- .../tests/functional/strongswan/test_strongswan_driver.py | 2 +- neutron_vpnaas/tests/unit/db/vpn/test_vpn_db.py | 2 +- neutron_vpnaas/tests/unit/db/vpn/test_vpn_validator.py | 2 +- .../tests/unit/extensions/test_vpn_endpoint_groups.py | 2 +- neutron_vpnaas/tests/unit/extensions/test_vpnaas.py | 2 +- .../tests/unit/services/vpn/common/test_netns_wrapper.py | 2 +- .../tests/unit/services/vpn/device_drivers/test_ipsec.py | 2 +- .../tests/unit/services/vpn/service_drivers/test_ipsec.py | 2 +- neutron_vpnaas/tests/unit/services/vpn/test_plugin.py | 2 +- neutron_vpnaas/tests/unit/services/vpn/test_vpn_service.py | 3 ++- test-requirements.txt | 1 - 14 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lower-constraints.txt b/lower-constraints.txt index 6890891b9..3938a5b22 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -47,7 +47,6 @@ logutils==0.3.5 Mako==0.4.0 MarkupSafe==1.0 mccabe==0.2.1 -mock==2.0.0 monotonic==0.6 mox3==0.20.0 msgpack-python==0.4.0 diff --git a/neutron_vpnaas/tests/functional/common/test_scenario.py b/neutron_vpnaas/tests/functional/common/test_scenario.py index 282c8198f..9d285aa72 100644 --- a/neutron_vpnaas/tests/functional/common/test_scenario.py +++ b/neutron_vpnaas/tests/functional/common/test_scenario.py @@ -13,8 +13,8 @@ import collections import copy import functools +from unittest import mock -import mock import netaddr from neutron.agent.common import ovs_lib from neutron.agent.l3 import agent as neutron_l3_agent diff --git a/neutron_vpnaas/tests/functional/openswan/test_openswan_driver.py b/neutron_vpnaas/tests/functional/openswan/test_openswan_driver.py index c639f88c0..5836342e2 100644 --- a/neutron_vpnaas/tests/functional/openswan/test_openswan_driver.py +++ b/neutron_vpnaas/tests/functional/openswan/test_openswan_driver.py @@ -13,7 +13,8 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock + from neutron.agent.linux import ip_lib from neutron.agent.linux import utils as linux_utils diff --git a/neutron_vpnaas/tests/functional/strongswan/test_strongswan_driver.py b/neutron_vpnaas/tests/functional/strongswan/test_strongswan_driver.py index 73d51b2fa..106921b79 100644 --- a/neutron_vpnaas/tests/functional/strongswan/test_strongswan_driver.py +++ b/neutron_vpnaas/tests/functional/strongswan/test_strongswan_driver.py @@ -14,8 +14,8 @@ # under the License. import os +from unittest import mock -import mock from neutron.agent.l3 import agent as neutron_l3_agent from neutron.agent.l3 import legacy_router from neutron.conf.agent.l3 import config as l3_config diff --git a/neutron_vpnaas/tests/unit/db/vpn/test_vpn_db.py b/neutron_vpnaas/tests/unit/db/vpn/test_vpn_db.py index d318fa7ac..d525fa2bb 100644 --- a/neutron_vpnaas/tests/unit/db/vpn/test_vpn_db.py +++ b/neutron_vpnaas/tests/unit/db/vpn/test_vpn_db.py @@ -17,8 +17,8 @@ import contextlib import copy import os +from unittest import mock -import mock from neutron.api import extensions as api_extensions from neutron.common import config from neutron.db import agentschedulers_db diff --git a/neutron_vpnaas/tests/unit/db/vpn/test_vpn_validator.py b/neutron_vpnaas/tests/unit/db/vpn/test_vpn_validator.py index 84d789ba3..c4fb35ef3 100644 --- a/neutron_vpnaas/tests/unit/db/vpn/test_vpn_validator.py +++ b/neutron_vpnaas/tests/unit/db/vpn/test_vpn_validator.py @@ -14,8 +14,8 @@ # under the License. import socket +from unittest import mock -import mock from neutron.db import l3_db from neutron_lib import context as n_ctx from neutron_lib import exceptions as nexception diff --git a/neutron_vpnaas/tests/unit/extensions/test_vpn_endpoint_groups.py b/neutron_vpnaas/tests/unit/extensions/test_vpn_endpoint_groups.py index 15f781eb2..adad0fa71 100644 --- a/neutron_vpnaas/tests/unit/extensions/test_vpn_endpoint_groups.py +++ b/neutron_vpnaas/tests/unit/extensions/test_vpn_endpoint_groups.py @@ -13,8 +13,8 @@ # under the License. import copy +from unittest import mock -import mock from oslo_utils import uuidutils from webob import exc diff --git a/neutron_vpnaas/tests/unit/extensions/test_vpnaas.py b/neutron_vpnaas/tests/unit/extensions/test_vpnaas.py index aa8440657..14d99832a 100644 --- a/neutron_vpnaas/tests/unit/extensions/test_vpnaas.py +++ b/neutron_vpnaas/tests/unit/extensions/test_vpnaas.py @@ -14,8 +14,8 @@ # under the License. import copy +from unittest import mock -import mock from neutron.tests.unit.api.v2 import test_base as test_api_v2 from neutron_lib.plugins import constants as nconstants from oslo_utils import uuidutils diff --git a/neutron_vpnaas/tests/unit/services/vpn/common/test_netns_wrapper.py b/neutron_vpnaas/tests/unit/services/vpn/common/test_netns_wrapper.py index 855212d8e..1a585d101 100644 --- a/neutron_vpnaas/tests/unit/services/vpn/common/test_netns_wrapper.py +++ b/neutron_vpnaas/tests/unit/services/vpn/common/test_netns_wrapper.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from neutron.tests import base from neutron_vpnaas.services.vpn.common import netns_wrapper as nswrap diff --git a/neutron_vpnaas/tests/unit/services/vpn/device_drivers/test_ipsec.py b/neutron_vpnaas/tests/unit/services/vpn/device_drivers/test_ipsec.py index 8a4ae2487..3a2c83986 100644 --- a/neutron_vpnaas/tests/unit/services/vpn/device_drivers/test_ipsec.py +++ b/neutron_vpnaas/tests/unit/services/vpn/device_drivers/test_ipsec.py @@ -17,8 +17,8 @@ import difflib import io import os import socket +from unittest import mock -import mock import netaddr from neutron.agent.l3 import dvr_edge_router from neutron.agent.l3 import dvr_snat_ns diff --git a/neutron_vpnaas/tests/unit/services/vpn/service_drivers/test_ipsec.py b/neutron_vpnaas/tests/unit/services/vpn/service_drivers/test_ipsec.py index 76a25a786..fdc114da9 100644 --- a/neutron_vpnaas/tests/unit/services/vpn/service_drivers/test_ipsec.py +++ b/neutron_vpnaas/tests/unit/services/vpn/service_drivers/test_ipsec.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from neutron.db import servicetype_db as st_db from neutron_lib import context as n_ctx diff --git a/neutron_vpnaas/tests/unit/services/vpn/test_plugin.py b/neutron_vpnaas/tests/unit/services/vpn/test_plugin.py index 346a2f2c9..aae20762d 100644 --- a/neutron_vpnaas/tests/unit/services/vpn/test_plugin.py +++ b/neutron_vpnaas/tests/unit/services/vpn/test_plugin.py @@ -13,8 +13,8 @@ # License for the specific language governing permissions and limitations # under the License. import contextlib +from unittest import mock -import mock from neutron.db import servicetype_db as st_db from neutron.services.flavors import flavors_plugin from neutron.tests.unit.db import test_agentschedulers_db diff --git a/neutron_vpnaas/tests/unit/services/vpn/test_vpn_service.py b/neutron_vpnaas/tests/unit/services/vpn/test_vpn_service.py index 3ec0ac8b2..e9a72cb01 100644 --- a/neutron_vpnaas/tests/unit/services/vpn/test_vpn_service.py +++ b/neutron_vpnaas/tests/unit/services/vpn/test_vpn_service.py @@ -13,7 +13,8 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock + from neutron_lib.callbacks import registry from oslo_config import cfg from oslo_utils import uuidutils diff --git a/test-requirements.txt b/test-requirements.txt index d7f2a0a6f..657ad0628 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -6,7 +6,6 @@ hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0 coverage!=4.4,>=4.0 # Apache-2.0 fixtures>=3.0.0 # Apache-2.0/BSD flake8-import-order==0.12 # LGPLv3 -mock>=2.0.0 # BSD pylint==2.3.0 # GPLv2 requests-mock>=1.2.0 # Apache-2.0 sphinx!=1.6.6,!=1.6.7,>=1.6.2;python_version>='3.4' # BSD