Removing dependency on the "mock" package

Now that we are python3 only, we should move to using the built
in version of mock that supports all of our testing needs and
remove the dependency on the "mock" package.

Also see commit: Ifcaf1c21bea0ec3c35278e49cecc90a101a82113

Change-Id: I58da980351fe14357c210c02eb167a6c0af9d09e
This commit is contained in:
asarfaty 2020-05-10 17:21:14 +02:00
parent e5640f074c
commit 5d2837c83a
65 changed files with 115 additions and 105 deletions

View File

@ -9,7 +9,6 @@ flake8==2.6.2
hacking==1.1.0
httplib2==0.9.1
kombu==4.0.0
mock==2.0.0
netaddr==0.7.18
neutron-lib==2.0.0
octavia-lib==1.3.1

View File

@ -29,7 +29,6 @@ oslo.vmware>=2.17.0 # Apache-2.0
PrettyTable<0.8,>=0.7.2 # BSD
tooz>=1.58.0 # Apache-2.0
decorator>=4.4.1 # BSD
mock>=2.0.0 # BSD
# These repos are installed from git in OpenStack CI if the job
# configures them as required-projects:

View File

@ -7,7 +7,6 @@ coverage!=4.4,>=4.0 # Apache-2.0
fixtures>=3.0.0 # Apache-2.0/BSD
flake8>=2.6.0
flake8-import-order==0.12 # LGPLv3
mock>=2.0.0 # BSD
psycopg2>=2.7 # LGPL/ZPL
PyMySQL>=0.7.6 # MIT License
oslotest>=3.2.0 # Apache-2.0

View File

@ -13,8 +13,9 @@
# License for the specific language governing permissions and limitations
# under the License.
from unittest import mock
import decorator
import mock
import netaddr
from oslo_config import cfg
from oslo_db import exception as db_exc

View File

@ -14,8 +14,8 @@
# under the License.
import copy
import time
from unittest import mock
import mock
import netaddr
from neutron_lib.api.definitions import address_scope

View File

@ -14,7 +14,7 @@
import time
import mock
from unittest import mock
from oslo_config import cfg
from oslo_log import log as logging

View File

@ -17,7 +17,7 @@
import os
import time
import mock
from unittest import mock
from vmware_nsx.api_client import client as nsx_client
from vmware_nsx.api_client import eventlet_client

View File

@ -13,7 +13,8 @@
# 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 import exceptions as n_exc

View File

@ -13,7 +13,8 @@
# 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 oslo_config import cfg
from oslo_utils import uuidutils

View File

@ -13,7 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import mock
from unittest import mock
from oslo_config import cfg
from oslo_vmware import api

View File

@ -12,7 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from neutron.tests.unit.db import test_db_base_plugin_v2 as test_db
from neutron_lib.db import api as db_api

View File

@ -12,7 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from neutron.tests.unit.db import test_db_base_plugin_v2 as test_db
from neutron_lib.db import api as db_api

View File

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

View File

@ -12,7 +12,7 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
import webob.exc
from neutron.db import db_base_plugin_v2

View File

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

View File

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

View File

@ -12,7 +12,7 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from neutron.tests.unit.extensions import test_securitygroup as test_ext_sg

View File

@ -13,9 +13,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import mock
import netaddr
from unittest import mock
import netaddr
from oslo_config import cfg
from oslo_utils import uuidutils

View File

@ -15,7 +15,7 @@
import copy
import mock
from unittest import mock
from neutron_lib.api.definitions import constants as fwaas_consts
from neutron_lib.plugins import directory

View File

@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import mock
from unittest import mock
from oslo_config import cfg
from oslo_utils import uuidutils

View File

@ -13,9 +13,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import mock
import netaddr
from unittest import mock
import netaddr
from oslo_config import cfg
from oslo_utils import uuidutils

View File

@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import mock
from unittest import mock
from oslo_config import cfg
from oslo_utils import uuidutils

View File

@ -12,8 +12,8 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from unittest import mock
import mock
from neutron.tests import base
from neutron_lib.plugins import constants

View File

@ -15,8 +15,8 @@
import copy
import datetime
from unittest import mock
import mock
from neutron.tests import base
from neutron_lib.plugins import constants

View File

@ -13,13 +13,14 @@
# License for the specific language governing permissions and limitations
# under the License.
from unittest import mock
from oslo_config import cfg
import mock
from neutron.services.flavors import flavors_plugin
from neutron.tests import base
from neutron_lib import context
from neutron_lib import exceptions as n_exc
from oslo_config import cfg
from vmware_nsx.db import nsxv_db
from vmware_nsx.services.lbaas import base_mgr

View File

@ -15,7 +15,7 @@
import copy
import mock
from unittest import mock
from neutron_lib.plugins import directory

View File

@ -12,8 +12,8 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from unittest import mock
import mock
from neutron.tests import base
from vmware_nsx.plugins.nsx_v.vshield import vcns_driver

View File

@ -12,11 +12,11 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import mock
from oslo_serialization import jsonutils
from unittest import mock
from neutron.tests import base
from oslo_serialization import jsonutils
from vmware_nsx.plugins.nsx_v.vshield import nsxv_loadbalancer
from vmware_nsx.plugins.nsx_v.vshield import vcns

View File

@ -16,11 +16,11 @@
import contextlib
import copy
import re
from unittest import mock
import decorator
from eventlet import greenthread
import mock
import netaddr
from neutron.db import securitygroups_db as sg_db
from neutron.extensions import address_scope

View File

@ -12,16 +12,16 @@
# License for the specific language governing permissions and limitations
# under the License.
#
from unittest import mock
import mock
from neutron.tests.unit import testlib_api
from neutron_lib import constants
from neutron_lib import context
from neutron_lib import exceptions as n_exc
from oslo_config import cfg
from oslo_utils import uuidutils
from six import moves
from neutron.tests.unit import testlib_api
from neutron_lib import exceptions as n_exc
from vmware_nsx.common import config as conf
from vmware_nsx.common import exceptions as nsx_exc
from vmware_nsx.common import nsxv_constants

View File

@ -12,9 +12,9 @@
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from unittest import mock
from eventlet import greenthread
import mock
from neutron.tests import base
from neutron_lib import context as neutron_context

View File

@ -12,8 +12,8 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from unittest import mock
import mock
from neutron.tests import base
from neutron_lib.plugins import constants
from oslo_utils import uuidutils

View File

@ -13,7 +13,8 @@
# 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.plugins import constants
from oslo_utils import uuidutils

View File

@ -13,7 +13,8 @@
# 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.plugins import constants
from oslo_utils import uuidutils

View File

@ -13,7 +13,8 @@
# 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.plugins import constants
from oslo_utils import uuidutils

View File

@ -13,7 +13,8 @@
# 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.plugins import constants
from oslo_utils import uuidutils

View File

@ -14,8 +14,8 @@
# limitations under the License.
import os
from unittest import mock
import mock
from oslo_config import cfg
from neutron.tests.unit import testlib_api

View File

@ -13,9 +13,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import mock
import netaddr
from unittest import mock
import netaddr
from oslo_config import cfg
from oslo_utils import uuidutils

View File

@ -14,8 +14,7 @@
# under the License.
import copy
import mock
from unittest import mock
from neutron_lib.plugins import directory

View File

@ -12,8 +12,8 @@
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from unittest import mock
import mock
import netaddr
from neutron.db import l3_db
from neutron.db import models_v2

View File

@ -13,8 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
from unittest import mock
import mock
from neutron.tests import base
from neutron.tests.unit.api.v2 import test_base

View File

@ -12,12 +12,13 @@
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from unittest import mock
import six
import mock
from neutron.tests import base
from neutron_lib import exceptions
from oslo_serialization import jsonutils
import six
from vmware_nsx.api_client import exception as api_exc
from vmware_nsx.common import exceptions as nsx_exc

View File

@ -15,8 +15,8 @@
#
import hashlib
from unittest import mock
import mock
from neutron.tests.unit.api.v2 import test_base
from neutron_lib import constants
from neutron_lib import exceptions

View File

@ -14,8 +14,8 @@
# under the License.
import re
from unittest import mock
import mock
from openstackclient.tests.unit.network.v2 import fakes as network_fakes
from openstackclient.tests.unit.network.v2 import test_port
from openstackclient.tests.unit import utils as tests_utils

View File

@ -14,8 +14,8 @@
# under the License.
import re
from unittest import mock
import mock
from openstackclient.tests.unit.network.v2 import test_router
from openstackclient.tests.unit import utils as tests_utils

View File

@ -14,13 +14,12 @@
# under the License.
import re
from unittest import mock
import mock
from openstackclient.tests.unit.network.v2 import (
test_security_group_network as test_security_group)
from openstackclient.tests.unit import utils as tests_utils
from vmware_nsx.extensions import providersecuritygroup
from vmware_nsx.extensions import securitygrouplogging
from vmware_nsx.extensions import securitygrouppolicy

View File

@ -14,8 +14,8 @@
# under the License.
import re
from unittest import mock
import mock
from openstackclient.tests.unit.network.v2 import test_subnet
from openstackclient.tests.unit import utils as tests_utils

View File

@ -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.api import extensions
from neutron_dynamic_routing.db import bgp_db # noqa
from neutron_dynamic_routing import extensions as dr_extensions

View File

@ -12,14 +12,11 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from oslo_config import cfg
from oslo_utils import importutils
from vmware_nsx.services.flowclassifier.nsx_v import driver as nsx_v_driver
from vmware_nsx.tests import unit as vmware
from vmware_nsx.tests.unit.nsx_v.vshield import fake_vcns
from neutron.api import extensions as api_ext
from neutron.common import config
from neutron_lib.api.definitions import portbindings
@ -33,6 +30,10 @@ from networking_sfc.services.flowclassifier.common import exceptions as fc_exc
from networking_sfc.tests import base
from networking_sfc.tests.unit.db import test_flowclassifier_db
from vmware_nsx.services.flowclassifier.nsx_v import driver as nsx_v_driver
from vmware_nsx.tests import unit as vmware
from vmware_nsx.tests.unit.nsx_v.vshield import fake_vcns
class TestNsxvFlowClassifierDriver(
test_flowclassifier_db.FlowClassifierDbPluginTestCaseBase,

View File

@ -12,9 +12,10 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import mock
import netaddr
from unittest import mock
import netaddr
from oslo_config import cfg
from oslo_utils import uuidutils

View File

@ -12,7 +12,8 @@
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import mock
from unittest import mock
from networking_l2gw.db.l2gateway import l2gateway_db
from networking_l2gw.services.l2gateway.common import config

View File

@ -12,13 +12,14 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import mock
from neutron.tests import base
from unittest import mock
from networking_l2gw.db.l2gateway import l2gateway_db
from neutron.tests import base
from neutron_lib import context
from neutron_lib import exceptions as n_exc
from vmware_nsx.common import exceptions as nsx_exc
from vmware_nsx.db import nsxv_db
from vmware_nsx.dvs import dvs_utils

View File

@ -13,7 +13,8 @@
# See the 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 import context
from neutron_lib import exceptions as n_exc

View File

@ -13,7 +13,8 @@
# See the 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 import context
from neutron_lib import exceptions as n_exc

View File

@ -12,9 +12,9 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from unittest import mock
import decorator
import mock
import testtools
from oslo_utils import uuidutils

View File

@ -12,8 +12,8 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from unittest import mock
import mock
import testtools
from neutron_lib import exceptions

View File

@ -12,7 +12,7 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 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 import exceptions

View File

@ -12,7 +12,7 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 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 import exceptions

View File

@ -13,8 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import copy
from unittest import mock
import mock
from neutron.services.qos import qos_plugin
from neutron.tests.unit.services.qos import base
from neutron_lib import context
@ -200,11 +200,7 @@ class TestQosNsxVNotification(test_plugin.NsxVPluginV2TestCase,
# make sure the dvs was updated
self.assertTrue(dvs_update_mock.called)
@mock.patch.object(qos_com_utils, 'update_network_policy_binding')
@mock.patch.object(dvs.DvsManager, 'update_port_groups_config')
def _test_rule_action_notification(self, action,
dvs_update_mock,
update_bindings_mock):
def _test_rule_action_notification(self, action):
# Create a policy with a rule
_policy = QosPolicy(
self.ctxt, **self.policy_data['policy'])
@ -212,9 +208,13 @@ class TestQosNsxVNotification(test_plugin.NsxVPluginV2TestCase,
# set the rule in the policy data
setattr(_policy, "rules", [self.rule])
with mock.patch('neutron.services.qos.qos_plugin.QoSPlugin.'
'get_policy',
return_value=_policy) as get_rules_mock,\
with mock.patch.object(qos_com_utils,
'update_network_policy_binding'),\
mock.patch.object(dvs.DvsManager, 'update_port_groups_config'
) as dvs_update_mock,\
mock.patch('neutron.services.qos.qos_plugin.QoSPlugin.'
'get_policy',
return_value=_policy) as get_rules_mock,\
mock.patch.object(QosPolicy, 'get_object', return_value=_policy):
# create the network to use this policy
net = self._create_net()
@ -265,11 +265,7 @@ class TestQosNsxVNotification(test_plugin.NsxVPluginV2TestCase,
"""
self._test_rule_action_notification('delete')
@mock.patch.object(qos_com_utils, 'update_network_policy_binding')
@mock.patch.object(dvs.DvsManager, 'update_port_groups_config')
def _test_dscp_rule_action_notification(self, action,
dvs_update_mock,
update_bindings_mock):
def _test_dscp_rule_action_notification(self, action):
# Create a policy with a rule
_policy = QosPolicy(
self.ctxt, **self.policy_data['policy'])
@ -277,9 +273,13 @@ class TestQosNsxVNotification(test_plugin.NsxVPluginV2TestCase,
# set the rule in the policy data
setattr(_policy, "rules", [self.dscp_rule])
plugin = self.qos_plugin
with mock.patch('neutron.services.qos.qos_plugin.QoSPlugin.'
'get_policy',
return_value=_policy) as rules_mock,\
with mock.patch.object(qos_com_utils,
'update_network_policy_binding'),\
mock.patch.object(dvs.DvsManager, 'update_port_groups_config'
) as dvs_update_mock,\
mock.patch('neutron.services.qos.qos_plugin.QoSPlugin.'
'get_policy',
return_value=_policy) as rules_mock,\
mock.patch.object(QosPolicy, 'get_object',
return_value=_policy),\
mock.patch.object(self.ctxt.session, 'expunge'):

View File

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

View File

@ -13,10 +13,9 @@
# See the 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 import context
from oslo_config import cfg
from oslo_utils import importutils

View File

@ -16,8 +16,7 @@
from collections import namedtuple
import contextlib
import mock
from oslo_utils import uuidutils
from unittest import mock
from neutron.db import l3_db
from neutron.db.models import l3 as l3_models
@ -26,6 +25,7 @@ from neutron_lib import context as n_ctx
from neutron_lib.plugins import directory
from neutron_vpnaas.db.vpn import vpn_models # noqa
from neutron_vpnaas.tests import base
from oslo_utils import uuidutils
from vmware_nsx.common import exceptions as nsx_exc
from vmware_nsx.services.vpnaas.nsxp import ipsec_driver

View File

@ -15,9 +15,7 @@
from collections import namedtuple
import contextlib
import mock
from oslo_utils import uuidutils
from unittest import mock
from neutron.db import l3_db
from neutron.db.models import l3 as l3_models
@ -26,6 +24,7 @@ from neutron_lib import context as n_ctx
from neutron_lib.plugins import directory
from neutron_vpnaas.db.vpn import vpn_models # noqa
from neutron_vpnaas.tests import base
from oslo_utils import uuidutils
from vmware_nsx.common import exceptions as nsx_exc
from vmware_nsx.services.vpnaas.nsxv3 import ipsec_driver
@ -726,5 +725,3 @@ class TestVpnaasDriver(test_plugin.NsxV3PluginTestCaseMixin):
self.driver.delete_vpnservice(
self.context, FAKE_VPNSERVICE)
delete_service.assert_called_once()
pass

View File

@ -15,7 +15,7 @@
import contextlib
import mock
from unittest import mock
from neutron_lib.api.definitions import external_net as extnet_apidef
from neutron_lib import context

View File

@ -15,7 +15,8 @@
import abc
import mock
from unittest import mock
from oslo_config import cfg
from oslo_log import _options
from oslo_log import log as logging
@ -296,7 +297,7 @@ class TestNsxvAdminUtils(AbstractTestAdminUtils,
except SystemExit:
return
else:
self.assertTrue(False)
self.fail()
class TestNsxv3AdminUtils(AbstractTestAdminUtils,