Use unittest.mock instead of mock

The mock third party library was needed for mock support in py2
runtimes. Since we now only support py38 and later, we can use the
standard lib unittest.mock module instead.

Change-Id: I009b6e65424ba3b662949baa1226fbf0ff14af80
This commit is contained in:
Xing Zhang 2023-06-27 11:14:25 +08:00
parent a3efd32a86
commit 193d1e2766
No known key found for this signature in database
GPG Key ID: 43F80E57B910E3B0
28 changed files with 45 additions and 28 deletions

View File

@ -13,9 +13,10 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from unittest import mock
import time import time
import mock
from neutron.agent.l3 import l3_agent_extension_api as l3_ext_api from neutron.agent.l3 import l3_agent_extension_api as l3_ext_api
from neutron.agent.linux import utils as linux_utils from neutron.agent.linux import utils as linux_utils
from neutron.tests.functional.agent.l3 import framework from neutron.tests.functional.agent.l3 import framework

View File

@ -12,7 +12,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import mock from unittest import mock
from oslo_config import cfg from oslo_config import cfg
from oslo_upgradecheck.upgradecheck import Code from oslo_upgradecheck.upgradecheck import Code

View File

@ -13,7 +13,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import mock from unittest import mock
import testtools import testtools
import webob.exc import webob.exc

View File

@ -14,9 +14,9 @@
# under the License. # under the License.
import socket import socket
from unittest import mock
import cffi import cffi
import mock
from neutron.tests import base from neutron.tests import base
from oslo_utils import importutils from oslo_utils import importutils
import testtools import testtools

View File

@ -13,7 +13,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import mock from unittest import mock
import testtools import testtools
from neutron_lib import constants from neutron_lib import constants

View File

@ -13,7 +13,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import mock from unittest import mock
import testtools import testtools
from neutron_fwaas.privileged import utils from neutron_fwaas.privileged import utils

View File

@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import mock from unittest import mock
from neutron import manager from neutron import manager
from neutron_fwaas.services.firewall.service_drivers.agents.drivers.linux.l2.\ from neutron_fwaas.services.firewall.service_drivers.agents.drivers.linux.l2.\

View File

@ -12,7 +12,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import mock from unittest import mock
from neutron_lib import constants from neutron_lib import constants
from neutron_lib.plugins.ml2 import ovs_constants as ovs_consts from neutron_lib.plugins.ml2 import ovs_constants as ovs_consts
import testtools import testtools

View File

@ -12,7 +12,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import mock from unittest import mock
from neutron_lib import constants from neutron_lib import constants
from neutron.tests import base from neutron.tests import base

View File

@ -15,7 +15,8 @@
import copy import copy
import mock from unittest import mock
from neutron.tests import base from neutron.tests import base
from neutron.tests.unit.api.v2 import test_base as test_api_v2 from neutron.tests.unit.api.v2 import test_base as test_api_v2

View File

@ -13,7 +13,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import mock from unittest import mock
import testtools import testtools
from neutron.tests import base from neutron.tests import base

View File

@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import mock from unittest import mock
from neutron_fwaas.services.firewall.service_drivers.agents.drivers.linux \ from neutron_fwaas.services.firewall.service_drivers.agents.drivers.linux \
import netlink_conntrack import netlink_conntrack

View File

@ -16,7 +16,8 @@
import copy import copy
import mock from unittest import mock
from neutron_lib import constants as nl_consts from neutron_lib import constants as nl_consts
from oslo_utils import uuidutils from oslo_utils import uuidutils

View File

@ -14,7 +14,8 @@
import copy import copy
import mock from unittest import mock
from neutron_lib import constants as nl_consts from neutron_lib import constants as nl_consts
from neutron_lib import context from neutron_lib import context
from neutron_lib.exceptions import firewall_v2 as f_exc from neutron_lib.exceptions import firewall_v2 as f_exc

View File

@ -13,7 +13,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import mock from unittest import mock
from neutron.agent.l3 import l3_agent_extension_api as l3_agent_api from neutron.agent.l3 import l3_agent_extension_api as l3_agent_api
from neutron.agent.l3 import router_info from neutron.agent.l3 import router_info
from neutron.agent.linux import ip_lib from neutron.agent.linux import ip_lib

View File

@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import mock from unittest import mock
from neutron.conf import common as common_conf from neutron.conf import common as common_conf
from neutron import extensions as neutron_extensions from neutron import extensions as neutron_extensions

View File

@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import mock from unittest import mock
from neutron_fwaas.services.firewall.service_drivers.agents.drivers \ from neutron_fwaas.services.firewall.service_drivers.agents.drivers \
import fwaas_base import fwaas_base

View File

@ -15,7 +15,8 @@
import copy import copy
import mock from unittest import mock
from neutron_lib.callbacks import events from neutron_lib.callbacks import events
from neutron_lib import context from neutron_lib import context

View File

@ -15,7 +15,7 @@
import contextlib import contextlib
import mock from unittest import mock
import webob.exc import webob.exc
from neutron.api import extensions as api_ext from neutron.api import extensions as api_ext

View File

@ -15,7 +15,8 @@
from collections import defaultdict from collections import defaultdict
import mock from unittest import mock
from neutron.tests.unit.api.v2 import test_base from neutron.tests.unit.api.v2 import test_base
from neutron_lib.services.logapi import constants as log_const from neutron_lib.services.logapi import constants as log_const

View File

@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import mock from unittest import mock
from neutron.api.rpc.callbacks.consumer import registry from neutron.api.rpc.callbacks.consumer import registry
from neutron.api.rpc.callbacks import resources from neutron.api.rpc.callbacks import resources

View File

@ -10,7 +10,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import mock from unittest import mock
from neutron.api.rpc.callbacks.consumer import registry as cons_registry from neutron.api.rpc.callbacks.consumer import registry as cons_registry
from neutron.api.rpc.callbacks.producer import registry as prod_registry from neutron.api.rpc.callbacks.producer import registry as prod_registry

View File

@ -13,7 +13,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import mock from unittest import mock
from neutron.objects import ports as port_objects from neutron.objects import ports as port_objects
from neutron.services.logapi.drivers import base as log_driver_base from neutron.services.logapi.drivers import base as log_driver_base
from neutron.services.logapi.drivers import manager as driver_mgr from neutron.services.logapi.drivers import manager as driver_mgr

View File

@ -13,7 +13,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import mock from unittest import mock
from neutron.objects.logapi import logging_resource as log_object from neutron.objects.logapi import logging_resource as log_object
from neutron.objects import ports as port_objects from neutron.objects import ports as port_objects
from neutron.services.logapi.rpc import server as server_rpc from neutron.services.logapi.rpc import server as server_rpc

View File

@ -13,7 +13,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import mock from unittest import mock
from neutron.objects import ports as port_objects from neutron.objects import ports as port_objects
from neutron.services.logapi.drivers import base as log_driver_base from neutron.services.logapi.drivers import base as log_driver_base
from neutron.services.logapi.drivers import manager as driver_mgr from neutron.services.logapi.drivers import manager as driver_mgr

View File

@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import mock from unittest import mock
from neutron.services.logapi.rpc import server as server_rpc from neutron.services.logapi.rpc import server as server_rpc
from neutron.tests import base from neutron.tests import base

View File

@ -13,7 +13,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import mock from unittest import mock
from neutron.objects import ports from neutron.objects import ports
from neutron.services.logapi.common import exceptions as log_exc from neutron.services.logapi.common import exceptions as log_exc
from neutron.services.logapi.common import validators from neutron.services.logapi.common import validators

View File

@ -5,7 +5,6 @@ hacking>=3.0.1,<3.1.0 # Apache-2.0
coverage!=4.4,>=4.0 # Apache-2.0 coverage!=4.4,>=4.0 # Apache-2.0
flake8-import-order==0.12 # LGPLv3 flake8-import-order==0.12 # LGPLv3
mock>=2.0.0 # BSD
python-subunit>=1.0.0 # Apache-2.0/BSD python-subunit>=1.0.0 # Apache-2.0/BSD
requests-mock>=1.2.0 # Apache-2.0 requests-mock>=1.2.0 # Apache-2.0
oslo.concurrency>=3.26.0 # Apache-2.0 oslo.concurrency>=3.26.0 # Apache-2.0