From 95cdf705a1e91cd693bd6ec6af2499ca3da545f9 Mon Sep 17 00:00:00 2001 From: Sean McGinnis Date: Sat, 18 Apr 2020 11:56:27 -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: Ic767e59531bc2515cc1c20675792fe88300e3f30 Signed-off-by: Sean McGinnis --- lower-constraints.txt | 1 - .../api/rpc/agentnotifiers/test_bgp_dr_rpc_agent_api.py | 4 ++-- .../tests/unit/api/rpc/handlers/test_bgp_speaker_rpc.py | 4 ++-- neutron_dynamic_routing/tests/unit/db/test_bgp_db.py | 2 +- .../tests/unit/services/bgp/agent/test_bgp_dragent.py | 2 +- .../tests/unit/services/bgp/driver/os_ken/test_driver.py | 7 +++---- .../services/bgp/scheduler/test_bgp_dragent_scheduler.py | 7 +++---- .../tests/unit/services/bgp/test_bgp_plugin.py | 2 +- test-requirements.txt | 1 - 9 files changed, 13 insertions(+), 17 deletions(-) diff --git a/lower-constraints.txt b/lower-constraints.txt index 00c3c82c..4c49eea7 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -45,7 +45,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_dynamic_routing/tests/unit/api/rpc/agentnotifiers/test_bgp_dr_rpc_agent_api.py b/neutron_dynamic_routing/tests/unit/api/rpc/agentnotifiers/test_bgp_dr_rpc_agent_api.py index 702271c2..824e6f7e 100644 --- a/neutron_dynamic_routing/tests/unit/api/rpc/agentnotifiers/test_bgp_dr_rpc_agent_api.py +++ b/neutron_dynamic_routing/tests/unit/api/rpc/agentnotifiers/test_bgp_dr_rpc_agent_api.py @@ -13,10 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -import mock -from neutron_lib import context +from unittest import mock from neutron.tests import base +from neutron_lib import context from neutron_dynamic_routing.api.rpc.agentnotifiers import bgp_dr_rpc_agent_api diff --git a/neutron_dynamic_routing/tests/unit/api/rpc/handlers/test_bgp_speaker_rpc.py b/neutron_dynamic_routing/tests/unit/api/rpc/handlers/test_bgp_speaker_rpc.py index 05e66ab5..032742a4 100644 --- a/neutron_dynamic_routing/tests/unit/api/rpc/handlers/test_bgp_speaker_rpc.py +++ b/neutron_dynamic_routing/tests/unit/api/rpc/handlers/test_bgp_speaker_rpc.py @@ -13,10 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -import mock -from neutron_lib.plugins import directory +from unittest import mock from neutron.tests import base +from neutron_lib.plugins import directory from neutron_dynamic_routing.api.rpc.handlers import bgp_speaker_rpc from neutron_dynamic_routing.extensions import bgp as bgp_ext diff --git a/neutron_dynamic_routing/tests/unit/db/test_bgp_db.py b/neutron_dynamic_routing/tests/unit/db/test_bgp_db.py index a2491118..71c7579c 100644 --- a/neutron_dynamic_routing/tests/unit/db/test_bgp_db.py +++ b/neutron_dynamic_routing/tests/unit/db/test_bgp_db.py @@ -13,8 +13,8 @@ # under the License. import contextlib +from unittest import mock -import mock import netaddr from neutron.db import l3_dvr_ha_scheduler_db from neutron.tests.unit.extensions import test_l3 diff --git a/neutron_dynamic_routing/tests/unit/services/bgp/agent/test_bgp_dragent.py b/neutron_dynamic_routing/tests/unit/services/bgp/agent/test_bgp_dragent.py index 35cc03e4..070af466 100644 --- a/neutron_dynamic_routing/tests/unit/services/bgp/agent/test_bgp_dragent.py +++ b/neutron_dynamic_routing/tests/unit/services/bgp/agent/test_bgp_dragent.py @@ -15,9 +15,9 @@ import copy import sys +from unittest import mock import eventlet -import mock from neutron_lib import context from oslo_config import cfg from oslo_utils import uuidutils diff --git a/neutron_dynamic_routing/tests/unit/services/bgp/driver/os_ken/test_driver.py b/neutron_dynamic_routing/tests/unit/services/bgp/driver/os_ken/test_driver.py index 3f281a95..3d7fbc9f 100644 --- a/neutron_dynamic_routing/tests/unit/services/bgp/driver/os_ken/test_driver.py +++ b/neutron_dynamic_routing/tests/unit/services/bgp/driver/os_ken/test_driver.py @@ -13,15 +13,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -import six +from unittest import mock -import mock +from neutron.tests import base from os_ken.services.protocols.bgp import bgpspeaker from os_ken.services.protocols.bgp.rtconf.neighbors import CONNECT_MODE_ACTIVE from oslo_config import cfg from oslo_utils import encodeutils - -from neutron.tests import base +import six from neutron_dynamic_routing.services.bgp.agent import config as bgp_config from neutron_dynamic_routing.services.bgp.agent.driver import exceptions as bgp_driver_exc # noqa diff --git a/neutron_dynamic_routing/tests/unit/services/bgp/scheduler/test_bgp_dragent_scheduler.py b/neutron_dynamic_routing/tests/unit/services/bgp/scheduler/test_bgp_dragent_scheduler.py index 37180696..14e51aec 100644 --- a/neutron_dynamic_routing/tests/unit/services/bgp/scheduler/test_bgp_dragent_scheduler.py +++ b/neutron_dynamic_routing/tests/unit/services/bgp/scheduler/test_bgp_dragent_scheduler.py @@ -13,15 +13,14 @@ # License for the specific language governing permissions and limitations # under the License. -import mock -import testscenarios +from unittest import mock +from neutron.tests.unit import testlib_api from neutron_lib.callbacks import events from neutron_lib.callbacks import registry from neutron_lib import context from oslo_utils import importutils - -from neutron.tests.unit import testlib_api +import testscenarios from neutron_dynamic_routing.api.rpc.callbacks import resources as dr_resources from neutron_dynamic_routing.db import bgp_db diff --git a/neutron_dynamic_routing/tests/unit/services/bgp/test_bgp_plugin.py b/neutron_dynamic_routing/tests/unit/services/bgp/test_bgp_plugin.py index 20d0e455..7e0d2f04 100644 --- a/neutron_dynamic_routing/tests/unit/services/bgp/test_bgp_plugin.py +++ b/neutron_dynamic_routing/tests/unit/services/bgp/test_bgp_plugin.py @@ -14,7 +14,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_lib.callbacks import events diff --git a/test-requirements.txt b/test-requirements.txt index 1a87d66b..bc0960e7 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -6,7 +6,6 @@ hacking>=1.1.0,<1.2.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 python-subunit>=1.0.0 # Apache-2.0/BSD sphinx!=1.6.6,!=1.6.7,!=2.1.0,>=1.6.5 # BSD sphinxcontrib-svg2pdfconverter>=0.1.0 # BSD