From 1da279b3ade831d38a84ff23a014bc671423ce3f Mon Sep 17 00:00:00 2001
From: Rodolfo Alonso Hernandez <ralonsoh@redhat.com>
Date: Thu, 12 Mar 2020 17:16:13 +0000
Subject: [PATCH] Use "unittest.mock" library and drop "mock" installation

As commented in [1], "unittest.mock" has been supported in the Python
internal unit testing framework since version 3.3.

[1]http://lists.openstack.org/pipermail/openstack-discuss/2020-March/013281.html

Change-Id: If71241a412ecfe3471a472802e18c986bd05d5b1
---
 doc/requirements.txt                                          | 1 -
 lower-constraints.txt                                         | 1 -
 neutron_lib/fixture.py                                        | 2 +-
 neutron_lib/tests/_base.py                                    | 2 +-
 neutron_lib/tests/unit/api/test_conversions.py                | 3 ++-
 .../tests/unit/api/validators/test_allowedaddresspairs.py     | 3 ++-
 .../tests/unit/api/validators/test_availability_zone.py       | 2 +-
 neutron_lib/tests/unit/api/validators/test_dns.py             | 2 +-
 neutron_lib/tests/unit/api/validators/test_validators.py      | 2 +-
 neutron_lib/tests/unit/callbacks/test_events.py               | 2 +-
 neutron_lib/tests/unit/callbacks/test_manager.py              | 2 +-
 neutron_lib/tests/unit/callbacks/test_registry.py             | 4 ++--
 neutron_lib/tests/unit/db/test_api.py                         | 3 ++-
 neutron_lib/tests/unit/db/test_model_query.py                 | 2 +-
 neutron_lib/tests/unit/db/test_utils.py                       | 2 +-
 neutron_lib/tests/unit/objects/test_utils.py                  | 2 +-
 neutron_lib/tests/unit/placement/test_client.py               | 2 +-
 neutron_lib/tests/unit/plugins/test_utils.py                  | 2 +-
 neutron_lib/tests/unit/policy/test__engine.py                 | 2 +-
 neutron_lib/tests/unit/services/qos/test_base.py              | 2 +-
 neutron_lib/tests/unit/test_context.py                        | 3 ++-
 neutron_lib/tests/unit/test_fixture.py                        | 2 +-
 neutron_lib/tests/unit/test_rpc.py                            | 2 +-
 neutron_lib/tests/unit/test_worker.py                         | 2 +-
 neutron_lib/tests/unit/utils/test_host.py                     | 3 +--
 neutron_lib/tests/unit/utils/test_net.py                      | 3 +--
 neutron_lib/tests/unit/utils/test_runtime.py                  | 3 ++-
 27 files changed, 31 insertions(+), 30 deletions(-)

diff --git a/doc/requirements.txt b/doc/requirements.txt
index a312749c7..bb2bb08cd 100644
--- a/doc/requirements.txt
+++ b/doc/requirements.txt
@@ -3,4 +3,3 @@ sphinx!=1.6.6,!=1.6.7,>=1.6.2;python_version>='3.4'  # BSD
 openstackdocstheme>=1.18.1 # Apache-2.0
 os-api-ref>=1.4.0 # Apache-2.0
 reno>=2.5.0 # Apache-2.0
-mock>=2.0.0 # BSD
diff --git a/lower-constraints.txt b/lower-constraints.txt
index 304bdabbb..5646ea2eb 100644
--- a/lower-constraints.txt
+++ b/lower-constraints.txt
@@ -28,7 +28,6 @@ linecache2==1.0.0
 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_lib/fixture.py b/neutron_lib/fixture.py
index 4cd352fc9..aa993573e 100644
--- a/neutron_lib/fixture.py
+++ b/neutron_lib/fixture.py
@@ -11,10 +11,10 @@
 # under the License.
 
 import copy
+from unittest import mock
 import warnings
 
 import fixtures
-import mock
 from oslo_config import cfg
 from oslo_db.sqlalchemy import enginefacade
 from oslo_db.sqlalchemy import provision
diff --git a/neutron_lib/tests/_base.py b/neutron_lib/tests/_base.py
index 5e68bbcbf..dd9e058d9 100644
--- a/neutron_lib/tests/_base.py
+++ b/neutron_lib/tests/_base.py
@@ -17,9 +17,9 @@ import logging as std_logging
 import os
 import os.path
 import random
+from unittest import mock
 
 import fixtures
-import mock
 from oslo_config import cfg
 from oslo_db import options as db_options
 from oslo_utils import strutils
diff --git a/neutron_lib/tests/unit/api/test_conversions.py b/neutron_lib/tests/unit/api/test_conversions.py
index f151cb077..d75f717d2 100644
--- a/neutron_lib/tests/unit/api/test_conversions.py
+++ b/neutron_lib/tests/unit/api/test_conversions.py
@@ -13,7 +13,8 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-import mock
+from unittest import mock
+
 import netaddr
 import testtools
 
diff --git a/neutron_lib/tests/unit/api/validators/test_allowedaddresspairs.py b/neutron_lib/tests/unit/api/validators/test_allowedaddresspairs.py
index b472f23af..b59045c3d 100644
--- a/neutron_lib/tests/unit/api/validators/test_allowedaddresspairs.py
+++ b/neutron_lib/tests/unit/api/validators/test_allowedaddresspairs.py
@@ -10,7 +10,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 webob import exc
 
diff --git a/neutron_lib/tests/unit/api/validators/test_availability_zone.py b/neutron_lib/tests/unit/api/validators/test_availability_zone.py
index 9194deead..32045bc4f 100644
--- a/neutron_lib/tests/unit/api/validators/test_availability_zone.py
+++ b/neutron_lib/tests/unit/api/validators/test_availability_zone.py
@@ -10,7 +10,7 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-import mock
+from unittest import mock
 
 from neutron_lib.api.validators import availability_zone as az_validator
 from neutron_lib.db import constants as db_const
diff --git a/neutron_lib/tests/unit/api/validators/test_dns.py b/neutron_lib/tests/unit/api/validators/test_dns.py
index bd0cfb22f..048997cd2 100644
--- a/neutron_lib/tests/unit/api/validators/test_dns.py
+++ b/neutron_lib/tests/unit/api/validators/test_dns.py
@@ -10,7 +10,7 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-import mock
+from unittest import mock
 
 from neutron_lib.api.validators import dns
 from neutron_lib.db import constants as db_constants
diff --git a/neutron_lib/tests/unit/api/validators/test_validators.py b/neutron_lib/tests/unit/api/validators/test_validators.py
index f4027204e..db0f41efe 100644
--- a/neutron_lib/tests/unit/api/validators/test_validators.py
+++ b/neutron_lib/tests/unit/api/validators/test_validators.py
@@ -12,8 +12,8 @@
 #    under the License.
 
 import string
+from unittest import mock
 
-import mock
 import netaddr
 
 from neutron_lib._i18n import _
diff --git a/neutron_lib/tests/unit/callbacks/test_events.py b/neutron_lib/tests/unit/callbacks/test_events.py
index 4e50e1b93..f3be8ac45 100644
--- a/neutron_lib/tests/unit/callbacks/test_events.py
+++ b/neutron_lib/tests/unit/callbacks/test_events.py
@@ -10,7 +10,7 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-import mock
+from unittest import mock
 
 from neutron_lib.callbacks import events
 from oslotest import base
diff --git a/neutron_lib/tests/unit/callbacks/test_manager.py b/neutron_lib/tests/unit/callbacks/test_manager.py
index 83a7741c3..f39e2f211 100644
--- a/neutron_lib/tests/unit/callbacks/test_manager.py
+++ b/neutron_lib/tests/unit/callbacks/test_manager.py
@@ -12,7 +12,7 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-import mock
+from unittest import mock
 
 from oslo_db import exception as db_exc
 from oslotest import base
diff --git a/neutron_lib/tests/unit/callbacks/test_registry.py b/neutron_lib/tests/unit/callbacks/test_registry.py
index 5b0aed8dd..eda98f4ac 100644
--- a/neutron_lib/tests/unit/callbacks/test_registry.py
+++ b/neutron_lib/tests/unit/callbacks/test_registry.py
@@ -12,10 +12,10 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-import mock
-import testtools
+from unittest import mock
 
 from oslotest import base
+import testtools
 
 from neutron_lib.callbacks import events
 from neutron_lib.callbacks import priority_group
diff --git a/neutron_lib/tests/unit/db/test_api.py b/neutron_lib/tests/unit/db/test_api.py
index d7454bf67..ffd61b3e7 100644
--- a/neutron_lib/tests/unit/db/test_api.py
+++ b/neutron_lib/tests/unit/db/test_api.py
@@ -11,7 +11,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-import mock
+from unittest import mock
+
 from oslo_db import exception as db_exc
 import osprofiler
 import sqlalchemy
diff --git a/neutron_lib/tests/unit/db/test_model_query.py b/neutron_lib/tests/unit/db/test_model_query.py
index b99b599fb..eb79d2e73 100644
--- a/neutron_lib/tests/unit/db/test_model_query.py
+++ b/neutron_lib/tests/unit/db/test_model_query.py
@@ -10,7 +10,7 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-import mock
+from unittest import mock
 
 from neutron_lib.db import model_query
 from neutron_lib import fixture
diff --git a/neutron_lib/tests/unit/db/test_utils.py b/neutron_lib/tests/unit/db/test_utils.py
index 2398a2147..0fdafaecf 100644
--- a/neutron_lib/tests/unit/db/test_utils.py
+++ b/neutron_lib/tests/unit/db/test_utils.py
@@ -10,7 +10,7 @@
 # License for the specific language governing permissions and limitations
 # under the License.
 
-import mock
+from unittest import mock
 
 from oslo_db.sqlalchemy import models
 import sqlalchemy as sa
diff --git a/neutron_lib/tests/unit/objects/test_utils.py b/neutron_lib/tests/unit/objects/test_utils.py
index ef15fa51c..6182b5324 100644
--- a/neutron_lib/tests/unit/objects/test_utils.py
+++ b/neutron_lib/tests/unit/objects/test_utils.py
@@ -10,7 +10,7 @@
 # License for the specific language governing permissions and limitations
 # under the License.
 
-import mock
+from unittest import mock
 
 from neutron_lib.objects import utils as obj_utils
 from neutron_lib.tests import _base as base
diff --git a/neutron_lib/tests/unit/placement/test_client.py b/neutron_lib/tests/unit/placement/test_client.py
index 371674ca8..d7124af7a 100644
--- a/neutron_lib/tests/unit/placement/test_client.py
+++ b/neutron_lib/tests/unit/placement/test_client.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 keystoneauth1 import exceptions as ks_exc
 from keystoneauth1 import loading as keystone
diff --git a/neutron_lib/tests/unit/plugins/test_utils.py b/neutron_lib/tests/unit/plugins/test_utils.py
index c9212eb88..963ba5934 100644
--- a/neutron_lib/tests/unit/plugins/test_utils.py
+++ b/neutron_lib/tests/unit/plugins/test_utils.py
@@ -13,8 +13,8 @@
 #    under the License.
 
 import hashlib
+from unittest import mock
 
-import mock
 from oslo_utils import excutils
 from oslo_utils import uuidutils
 
diff --git a/neutron_lib/tests/unit/policy/test__engine.py b/neutron_lib/tests/unit/policy/test__engine.py
index ae7a101b6..872fc0a2f 100644
--- a/neutron_lib/tests/unit/policy/test__engine.py
+++ b/neutron_lib/tests/unit/policy/test__engine.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 neutron_lib import context
 from neutron_lib.policy import _engine as policy_engine
diff --git a/neutron_lib/tests/unit/services/qos/test_base.py b/neutron_lib/tests/unit/services/qos/test_base.py
index d4aee1e0b..cf99a081d 100644
--- a/neutron_lib/tests/unit/services/qos/test_base.py
+++ b/neutron_lib/tests/unit/services/qos/test_base.py
@@ -12,7 +12,7 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-import mock
+from unittest import mock
 
 from neutron_lib.api.definitions import portbindings
 from neutron_lib import constants
diff --git a/neutron_lib/tests/unit/test_context.py b/neutron_lib/tests/unit/test_context.py
index 4bbb3b637..f3880a465 100644
--- a/neutron_lib/tests/unit/test_context.py
+++ b/neutron_lib/tests/unit/test_context.py
@@ -10,7 +10,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/neutron_lib/tests/unit/test_fixture.py b/neutron_lib/tests/unit/test_fixture.py
index 2e292a2ec..4e56b4709 100644
--- a/neutron_lib/tests/unit/test_fixture.py
+++ b/neutron_lib/tests/unit/test_fixture.py
@@ -11,8 +11,8 @@
 # under the License.
 
 import re
+from unittest import mock
 
-import mock
 from oslo_config import cfg
 from oslo_db import options
 from oslotest import base
diff --git a/neutron_lib/tests/unit/test_rpc.py b/neutron_lib/tests/unit/test_rpc.py
index 8d63573a7..9d2392b89 100644
--- a/neutron_lib/tests/unit/test_rpc.py
+++ b/neutron_lib/tests/unit/test_rpc.py
@@ -10,7 +10,7 @@
 # License for the specific language governing permissions and limitations
 # under the License.
 
-import mock
+from unittest import mock
 
 from oslo_config import cfg
 import oslo_messaging as messaging
diff --git a/neutron_lib/tests/unit/test_worker.py b/neutron_lib/tests/unit/test_worker.py
index 9340cea16..1bcc7cacf 100644
--- a/neutron_lib/tests/unit/test_worker.py
+++ b/neutron_lib/tests/unit/test_worker.py
@@ -12,7 +12,7 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-import mock
+from unittest import mock
 
 from neutron_lib.callbacks import events
 from neutron_lib.callbacks import resources
diff --git a/neutron_lib/tests/unit/utils/test_host.py b/neutron_lib/tests/unit/utils/test_host.py
index df19d7fde..e87e7a8d0 100644
--- a/neutron_lib/tests/unit/utils/test_host.py
+++ b/neutron_lib/tests/unit/utils/test_host.py
@@ -12,8 +12,7 @@
 # limitations under the License.
 
 import multiprocessing
-
-import mock
+from unittest import mock
 
 from neutron_lib.tests import _base as base
 from neutron_lib.utils import host
diff --git a/neutron_lib/tests/unit/utils/test_net.py b/neutron_lib/tests/unit/utils/test_net.py
index 0a8c36721..bb243b311 100644
--- a/neutron_lib/tests/unit/utils/test_net.py
+++ b/neutron_lib/tests/unit/utils/test_net.py
@@ -14,8 +14,7 @@
 import itertools
 import random
 import socket
-
-import mock
+from unittest import mock
 
 from neutron_lib import constants
 from neutron_lib.tests import _base as base
diff --git a/neutron_lib/tests/unit/utils/test_runtime.py b/neutron_lib/tests/unit/utils/test_runtime.py
index b22cd3b6f..13da34af5 100644
--- a/neutron_lib/tests/unit/utils/test_runtime.py
+++ b/neutron_lib/tests/unit/utils/test_runtime.py
@@ -11,7 +11,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-import mock
+from unittest import mock
+
 from stevedore import enabled
 
 from neutron_lib.tests import _base as base