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: I130c03e12ddc53ce7ced728a43b10b142f7b066f
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
Co-Authored-By: Hiroo Kitamura <hiroo.kitamura@ntt-at.co.jp>
This commit is contained in:
Sean McGinnis 2020-04-18 12:00:58 -05:00 committed by Hiroo Kitamura
parent 264ef947c3
commit 41a21bc807
52 changed files with 75 additions and 63 deletions

View File

@ -53,7 +53,6 @@ linecache2==1.0.0
Mako==1.0.7 Mako==1.0.7
MarkupSafe==1.0 MarkupSafe==1.0
mccabe==0.2.1 mccabe==0.2.1
mock==3.0.0
monotonic==1.4 monotonic==1.4
mox3==0.25.0 mox3==0.25.0
msgpack==0.5.6 msgpack==0.5.6

View File

@ -87,7 +87,7 @@ def validate_head_file(config):
if len(script.get_heads()) > 1: if len(script.get_heads()) > 1:
alembic_util.err(_('Timeline branches unable to generate timeline')) alembic_util.err(_('Timeline branches unable to generate timeline'))
head_path = os.path.join(script.versions, HEAD_FILENAME) head_path = os.path.join(str(script.versions), HEAD_FILENAME)
if (os.path.isfile(head_path) and if (os.path.isfile(head_path) and
open(head_path).read().strip() == script.get_current_head()): open(head_path).read().strip() == script.get_current_head()):
return return
@ -100,7 +100,7 @@ def update_head_file(config):
if len(script.get_heads()) > 1: if len(script.get_heads()) > 1:
alembic_util.err(_('Timeline branches unable to generate timeline')) alembic_util.err(_('Timeline branches unable to generate timeline'))
head_path = os.path.join(script.versions, HEAD_FILENAME) head_path = os.path.join(str(script.versions), HEAD_FILENAME)
with open(head_path, 'w+') as f: with open(head_path, 'w+') as f:
f.write(script.get_current_head()) f.write(script.get_current_head())

View File

@ -21,11 +21,11 @@ import logging
import os import os
import os.path import os.path
import sys import sys
from unittest import mock
import weakref import weakref
import eventlet.timeout import eventlet.timeout
import fixtures import fixtures
import mock
from oslo_config import cfg from oslo_config import cfg
from oslo_messaging import conffixture as messaging_conffixture from oslo_messaging import conffixture as messaging_conffixture
import testtools import testtools

View File

@ -13,7 +13,7 @@
# under the License. # under the License.
import mock from unittest import mock
import oslo_i18n import oslo_i18n

View File

@ -14,7 +14,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_utils import uuidutils from oslo_utils import uuidutils
from webob import exc from webob import 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 webob import exc from webob import exc
import webtest import webtest

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 tacker import manager from tacker import manager

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 oslo_serialization import jsonutils from oslo_serialization import jsonutils

View File

@ -13,8 +13,9 @@
# 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 ddt import ddt
import mock
import six import six
from webob import exc from webob import exc

View File

@ -14,8 +14,8 @@
# under the License. # under the License.
import os import os
from unittest import mock
import mock
from oslo_config import cfg from oslo_config import cfg
from oslo_policy import policy as common_policy from oslo_policy import policy as common_policy
from oslo_utils import uuidutils from oslo_utils import uuidutils

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 oslo_config import cfg from oslo_config import cfg
from oslo_config import fixture as config_fixture from oslo_config import fixture as config_fixture
from requests_mock.contrib import fixture as requests_mock_fixture from requests_mock.contrib import fixture as requests_mock_fixture

View File

@ -14,8 +14,8 @@
# limitations under the License. # limitations under the License.
import os import os
from unittest import mock
import mock
from oslo_config import cfg from oslo_config import cfg
from tacker.common import config from tacker.common import config

View File

@ -12,10 +12,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.
import mock
import os import os
import shutil import shutil
import testtools import testtools
from unittest import mock
from tacker.common import csar_utils from tacker.common import csar_utils
from tacker.common import exceptions from tacker.common import exceptions

View File

@ -12,7 +12,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 tacker.common import log as call_log from tacker.common import log as call_log
from tacker.tests import base from tacker.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 tacker.common.rpc import BackingOffClient from tacker.common.rpc import BackingOffClient
from tacker.conductor.conductorrpc import vnf_pkgm_rpc from tacker.conductor.conductorrpc import vnf_pkgm_rpc

View File

@ -14,12 +14,12 @@
# limitations under the License. # limitations under the License.
import os import os
from oslo_config import cfg
import shutil import shutil
import sys import sys
from unittest import mock
from glance_store import exceptions as store_exceptions from glance_store import exceptions as store_exceptions
import mock from oslo_config import cfg
from six.moves import urllib from six.moves import urllib
import six.moves.urllib.error as urlerr import six.moves.urllib.error as urlerr
import yaml import yaml

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 oslo_utils import timeutils from oslo_utils import timeutils

View File

@ -16,8 +16,8 @@
# @author Mark McClain (DreamHost) # @author Mark McClain (DreamHost)
import sys import sys
from unittest import mock
import mock
from tacker.db.migration import cli from tacker.db.migration import cli
from tacker.tests import base from tacker.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 tacker.common import exceptions from tacker.common import exceptions

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 oslo_utils import timeutils from oslo_utils import timeutils

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
import glance_store import glance_store
from six.moves import urllib from six.moves import urllib

View File

@ -13,7 +13,8 @@
# under the License. # under the License.
from collections import namedtuple from collections import namedtuple
import mock from unittest import mock
from oslo_config import cfg from oslo_config import cfg
from tacker import context as t_context from tacker import context as t_context

View File

@ -14,9 +14,9 @@
# under the License. # under the License.
import os import os
from unittest import mock
from keystoneauth1 import exceptions from keystoneauth1 import exceptions
import mock
from oslo_config import cfg from oslo_config import cfg
from tacker import context as t_context from tacker import context as t_context

View File

@ -11,7 +11,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 oslo_utils import uuidutils from oslo_utils import uuidutils

View File

@ -15,11 +15,11 @@
import codecs import codecs
from datetime import datetime from datetime import datetime
import mock
import os import os
from oslo_utils import uuidutils from unittest import mock
from unittest.mock import patch
from mock import patch from oslo_utils import uuidutils
from tacker.common import exceptions from tacker.common import exceptions
from tacker import context from tacker import context

View File

@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import mock from unittest import mock
from tacker.common import exceptions from tacker.common import exceptions
from tacker import context from tacker import context

View File

@ -13,16 +13,16 @@
# 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 tacker.common import exceptions from tacker.common import exceptions
from tacker import context from tacker import context
from tacker.db import api as sqlalchemy_api
from tacker import objects from tacker import objects
from tacker.tests.unit.db.base import SqlTestCase from tacker.tests.unit.db.base import SqlTestCase
from tacker.tests.unit.objects import fakes from tacker.tests.unit.objects import fakes
from tacker.tests import uuidsentinel from tacker.tests import uuidsentinel
from tacker.db import api as sqlalchemy_api
get_engine = sqlalchemy_api.get_engine get_engine = sqlalchemy_api.get_engine

View File

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

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 tacker.common import exceptions from tacker.common import exceptions
from tacker import context from tacker import context

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 oslo_serialization import jsonutils from oslo_serialization import jsonutils
from webob import Request from webob import Request

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 oslo_context import context as oslo_context from oslo_context import context as oslo_context
from testtools import matchers from testtools import matchers

View File

@ -15,8 +15,9 @@
"""Test of Policy Engine For Tacker""" """Test of Policy Engine For Tacker"""
from unittest import mock
import fixtures import fixtures
import mock
import six import six
from oslo_policy import policy as common_policy from oslo_policy import policy as common_policy

View File

@ -14,10 +14,11 @@
# under the License. # under the License.
import os import os
from unittest import mock
import oslo_i18n import oslo_i18n
import socket import socket
import mock
from oslo_config import cfg from oslo_config import cfg
import six.moves.urllib.request as urllibrequest import six.moves.urllib.request as urllibrequest
import testtools import testtools

View File

@ -14,8 +14,8 @@
# under the License. # under the License.
import sys import sys
from unittest import mock
import mock
from six import moves from six import moves
from tacker.tests import base from tacker.tests import base

View File

@ -12,9 +12,9 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# 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 ddt import ddt
import mock
from oslo_serialization import jsonutils from oslo_serialization import jsonutils
from six.moves import http_client from six.moves import http_client
from webob import exc from webob import exc

View File

@ -14,10 +14,11 @@
# limitations under the License. # limitations under the License.
import os import os
import shutil import shutil
from unittest import mock
import fixtures import fixtures
import mock
from oslo_config import cfg from oslo_config import cfg
from tacker.common import exceptions from tacker.common import exceptions
from tacker.common import utils from tacker.common import utils
from tacker import context from tacker import context

View File

@ -15,8 +15,7 @@
import codecs import codecs
import os import os
from unittest import mock
import mock
import yaml import yaml
from oslo_serialization import jsonutils from oslo_serialization import jsonutils

View File

@ -13,13 +13,14 @@
# 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 ddt
import importlib import importlib
import json import json
import mock
import os import os
import requests
import tempfile import tempfile
from unittest import mock
import ddt
import requests
import yaml import yaml
from tacker.common import exceptions from tacker.common import exceptions

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 tacker import context from tacker import context
from tacker.db.common_services import common_services_db_plugin from tacker.db.common_services import common_services_db_plugin

View File

@ -12,7 +12,8 @@
# under the License. # under the License.
# #
import mock from unittest import mock
import six.moves.urllib.error as urlerr import six.moves.urllib.error as urlerr
import testtools import testtools

View File

@ -12,8 +12,8 @@
# under the License. # under the License.
# #
import mock
import testtools import testtools
from unittest import mock
from tacker.vnfm.monitor_drivers.ping import ping from tacker.vnfm.monitor_drivers.ping import ping

View File

@ -12,9 +12,9 @@
# under the License. # under the License.
# #
import mock
from tacker.vnfm.monitor_drivers.zabbix import zabbix from tacker.vnfm.monitor_drivers.zabbix import zabbix
import testtools import testtools
from unittest import mock
class TestVNFMonitorZabbix(testtools.TestCase): class TestVNFMonitorZabbix(testtools.TestCase):

View File

@ -12,8 +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
import testtools import testtools
from unittest import mock
from tacker import context from tacker import context
from tacker.db.common_services import common_services_db_plugin from tacker.db.common_services import common_services_db_plugin

View File

@ -12,8 +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
import testtools import testtools
from unittest import mock
from tacker import context from tacker import context
from tacker.db.common_services import common_services_db_plugin from tacker.db.common_services import common_services_db_plugin

View File

@ -12,8 +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
import testtools import testtools
from unittest import mock
from tacker.common import clients from tacker.common import clients
from tacker import context from tacker import context

View File

@ -13,8 +13,8 @@
# #
from datetime import datetime from datetime import datetime
from unittest import mock
import mock
from oslo_utils import uuidutils from oslo_utils import uuidutils
from tacker import context from tacker import context

View File

@ -14,10 +14,10 @@
# under the License. # under the License.
from datetime import datetime from datetime import datetime
from unittest import mock
import mock
from oslo_utils import uuidutils from oslo_utils import uuidutils
from tacker import context from tacker import context
from tacker.db.common_services import common_services_db_plugin from tacker.db.common_services import common_services_db_plugin
from tacker.db.nfvo import nfvo_db from tacker.db.nfvo import nfvo_db

View File

@ -12,7 +12,8 @@
# under the License. # under the License.
# #
import mock from unittest import mock
from oslo_serialization import jsonutils from oslo_serialization import jsonutils
from oslo_utils import timeutils from oslo_utils import timeutils
import testtools import testtools

View File

@ -14,10 +14,10 @@
# under the License. # under the License.
from datetime import datetime from datetime import datetime
from unittest import mock
from unittest.mock import patch
import ddt import ddt
import mock
from mock import patch
from oslo_utils import uuidutils from oslo_utils import uuidutils
import yaml import yaml

View File

@ -10,8 +10,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 sqlalchemy.orm import exc as orm_exc from sqlalchemy.orm import exc as orm_exc
from unittest import mock
from tacker.extensions import nfvo from tacker.extensions import nfvo
from tacker import manager from tacker import manager

View File

@ -12,8 +12,9 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# 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 ddt import ddt
import mock
from oslo_serialization import jsonutils from oslo_serialization import jsonutils
from six.moves import http_client from six.moves import http_client
from six.moves import urllib from six.moves import urllib

View File

@ -9,7 +9,6 @@ ddt>=1.0.1 # MIT
doc8>=0.6.0 # Apache-2.0 doc8>=0.6.0 # Apache-2.0
fixtures>=3.0.0 # Apache-2.0/BSD fixtures>=3.0.0 # Apache-2.0/BSD
hacking>=3.0.1,<3.1.0 # Apache-2.0 hacking>=3.0.1,<3.1.0 # Apache-2.0
mock>=3.0.0 # BSD
python-subunit>=1.0.0 # Apache-2.0/BSD python-subunit>=1.0.0 # Apache-2.0/BSD
python-tackerclient>=0.8.0 # Apache-2.0 python-tackerclient>=0.8.0 # Apache-2.0
oslotest>=3.2.0 # Apache-2.0 oslotest>=3.2.0 # Apache-2.0