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: Ia41326a601dfd72750bd81c3ebee9ec5884ad91b
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
This commit is contained in:
Sean McGinnis 2020-04-18 11:57:42 -05:00
parent 1021aee31f
commit 4e24fd614b
14 changed files with 32 additions and 35 deletions

@ -13,17 +13,17 @@
# 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 cinderclient import api_versions from cinderclient import api_versions
from cinderclient import client as base_client from cinderclient import client as base_client
from cinderclient import exceptions from cinderclient import exceptions
from cinderclient.v3 import client
from cinderclient.tests.unit import test_utils from cinderclient.tests.unit import test_utils
from cinderclient.tests.unit import utils from cinderclient.tests.unit import utils
from cinderclient.v3 import client
@ddt.ddt @ddt.ddt

@ -12,30 +12,28 @@
# 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 requests import Response
import requests
import six import six
from cinderclient import api_versions from cinderclient import api_versions
from cinderclient.apiclient import base as common_base from cinderclient.apiclient import base as common_base
from cinderclient import base from cinderclient import base
from cinderclient import exceptions from cinderclient import exceptions
from cinderclient.v3 import client
from cinderclient.v3 import volumes
from cinderclient.tests.unit import test_utils from cinderclient.tests.unit import test_utils
from cinderclient.tests.unit import utils from cinderclient.tests.unit import utils
from cinderclient.tests.unit.v2 import fakes from cinderclient.tests.unit.v2 import fakes
from cinderclient.v3 import client
from cinderclient.v3 import volumes
cs = fakes.FakeClient() cs = fakes.FakeClient()
REQUEST_ID = 'req-test-request-id' REQUEST_ID = 'req-test-request-id'
def create_response_obj_with_header(): def create_response_obj_with_header():
resp = Response() resp = requests.Response()
resp.headers['x-openstack-request-id'] = REQUEST_ID resp.headers['x-openstack-request-id'] = REQUEST_ID
resp.headers['Etag'] = 'd5103bf7b26ff0310200d110da3ed186' resp.headers['Etag'] = 'd5103bf7b26ff0310200d110da3ed186'
resp.status_code = 200 resp.status_code = 200

@ -13,22 +13,21 @@
import json import json
import logging import logging
from unittest import mock
import ddt import ddt
import fixtures import fixtures
from keystoneauth1 import adapter from keystoneauth1 import adapter
from keystoneauth1 import exceptions as keystone_exception from keystoneauth1 import exceptions as keystone_exception
import mock
from oslo_serialization import jsonutils from oslo_serialization import jsonutils
import six import six
from cinderclient import api_versions from cinderclient import api_versions
import cinderclient.client import cinderclient.client
from cinderclient import exceptions from cinderclient import exceptions
import cinderclient.v2.client
from cinderclient.tests.unit import utils from cinderclient.tests.unit import utils
from cinderclient.tests.unit.v3 import fakes from cinderclient.tests.unit.v3 import fakes
import cinderclient.v2.client
@ddt.ddt @ddt.ddt

@ -15,7 +15,8 @@
"""Tests the cinderclient.exceptions module.""" """Tests the cinderclient.exceptions module."""
import datetime import datetime
import mock from unittest import mock
import requests import requests
from cinderclient import exceptions from cinderclient import exceptions

@ -12,10 +12,11 @@
# limitations under the License. # limitations under the License.
import json import json
import mock from unittest import mock
import requests
import uuid import uuid
import requests
from cinderclient import client from cinderclient import client
from cinderclient import exceptions from cinderclient import exceptions
from cinderclient.tests.unit import utils from cinderclient.tests.unit import utils

@ -15,6 +15,7 @@ import argparse
import re import re
import sys import sys
import unittest import unittest
from unittest import mock
import ddt import ddt
import fixtures import fixtures
@ -22,7 +23,6 @@ import keystoneauth1.exceptions as ks_exc
from keystoneauth1.exceptions import DiscoveryFailure from keystoneauth1.exceptions import DiscoveryFailure
from keystoneauth1.identity.generic.password import Password as ks_password from keystoneauth1.identity.generic.password import Password as ks_password
from keystoneauth1 import session from keystoneauth1 import session
import mock
import requests_mock import requests_mock
from six import moves from six import moves
from testtools import matchers from testtools import matchers

@ -12,10 +12,10 @@
# limitations under the License. # limitations under the License.
import collections import collections
import ddt
import sys import sys
from unittest import mock
import mock import ddt
import six import six
from six import moves from six import moves
@ -24,10 +24,9 @@ from cinderclient.apiclient import base as common_base
from cinderclient import base from cinderclient import base
from cinderclient import exceptions from cinderclient import exceptions
from cinderclient import shell_utils from cinderclient import shell_utils
from cinderclient import utils
from cinderclient.tests.unit import utils as test_utils from cinderclient.tests.unit import utils as test_utils
from cinderclient.tests.unit.v2 import fakes from cinderclient.tests.unit.v2 import fakes
from cinderclient import utils
UUID = '8e8ec658-c7b0-4243-bdf8-6f7f2952c0d0' UUID = '8e8ec658-c7b0-4243-bdf8-6f7f2952c0d0'

@ -13,9 +13,9 @@
import json import json
import os import os
from unittest import mock
import fixtures import fixtures
import mock
import requests import requests
from requests_mock.contrib import fixture as requests_mock_fixture from requests_mock.contrib import fixture as requests_mock_fixture
import six import six

@ -15,14 +15,13 @@
# under the License. # under the License.
import json import json
from unittest import mock
import mock
import requests import requests
from cinderclient import exceptions from cinderclient import exceptions
from cinderclient.v2 import client
from cinderclient.tests.unit import utils from cinderclient.tests.unit import utils
from cinderclient.v2 import client
class AuthenticateAgainstKeystoneTests(utils.TestCase): class AuthenticateAgainstKeystoneTests(utils.TestCase):

@ -13,8 +13,9 @@
# 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.
from unittest import mock
import ddt import ddt
import mock
from cinderclient.tests.unit import utils from cinderclient.tests.unit import utils
from cinderclient.v2 import limits from cinderclient.v2 import limits

@ -13,22 +13,22 @@
# 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 fixtures import fixtures
import mock
from requests_mock.contrib import fixture as requests_mock_fixture from requests_mock.contrib import fixture as requests_mock_fixture
from six.moves.urllib import parse from six.moves.urllib import parse
from cinderclient import client from cinderclient import client
from cinderclient import exceptions from cinderclient import exceptions
from cinderclient import shell from cinderclient import shell
from cinderclient.v2 import shell as test_shell
from cinderclient.v2 import volume_backups
from cinderclient.v2 import volumes
from cinderclient.tests.unit.fixture_data import keystone_client from cinderclient.tests.unit.fixture_data import keystone_client
from cinderclient.tests.unit import utils from cinderclient.tests.unit import utils
from cinderclient.tests.unit.v2 import fakes from cinderclient.tests.unit.v2 import fakes
from cinderclient.v2 import shell as test_shell
from cinderclient.v2 import volume_backups
from cinderclient.v2 import volumes
@ddt.ddt @ddt.ddt

@ -38,9 +38,10 @@
# 'volume_id': '1234'}) # 'volume_id': '1234'})
# return original(manager, name_or_id, **kwargs) # return original(manager, name_or_id, **kwargs)
from unittest import mock
import ddt import ddt
import fixtures import fixtures
import mock
from requests_mock.contrib import fixture as requests_mock_fixture from requests_mock.contrib import fixture as requests_mock_fixture
import six import six
from six.moves.urllib import parse from six.moves.urllib import parse

@ -16,7 +16,6 @@ jsonschema==2.6.0
keystoneauth1==3.4.0 keystoneauth1==3.4.0
linecache2==1.0.0 linecache2==1.0.0
mccabe==0.2.1 mccabe==0.2.1
mock==2.0.0
monotonic==0.6 monotonic==0.6
msgpack-python==0.4.0 msgpack-python==0.4.0
netaddr==0.7.18 netaddr==0.7.18

@ -7,7 +7,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
ddt>=1.0.1 # MIT ddt>=1.0.1 # MIT
fixtures>=3.0.0 # Apache-2.0/BSD fixtures>=3.0.0 # Apache-2.0/BSD
mock>=2.0.0 # BSD
reno>=3.1.0 # Apache-2.0 reno>=3.1.0 # Apache-2.0
requests-mock>=1.2.0 # Apache-2.0 requests-mock>=1.2.0 # Apache-2.0
tempest>=17.1.0 # Apache-2.0 tempest>=17.1.0 # Apache-2.0