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: I2bb5204c1ee88d0b0cd6df830dac80d37bfddcf2
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
This commit is contained in:
Sean McGinnis 2020-03-20 15:01:15 -05:00 committed by Douglas Mendizábal
parent b8266ef402
commit 32a7100358
39 changed files with 64 additions and 60 deletions

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_serialization import jsonutils as json from oslo_serialization import jsonutils as json
from oslo_utils import uuidutils from oslo_utils import uuidutils

View File

@ -14,8 +14,8 @@
# limitations under the License. # limitations under the License.
import base64 import base64
import os import os
from unittest import mock
import mock
from oslo_utils import timeutils from oslo_utils import timeutils
from barbican.api.controllers import secrets from barbican.api.controllers import secrets

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_utils import uuidutils from oslo_utils import uuidutils
from barbican.model import models from barbican.model import models

View File

@ -12,7 +12,8 @@
# implied. # implied.
# 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
import oslotest.base as oslotest import oslotest.base as oslotest
from barbican.api.middleware import context from barbican.api.middleware import context

View File

@ -12,8 +12,7 @@
# limitations under the License. # limitations under the License.
import unittest import unittest
from unittest import mock
import mock
from barbican.api.middleware import simple from barbican.api.middleware import simple

View File

@ -14,7 +14,7 @@
""" """
This test module tests the barbican.api.__init__.py module functionality. This test module tests the barbican.api.__init__.py module functionality.
""" """
import mock from unittest import mock
from oslo_serialization import jsonutils as json from oslo_serialization import jsonutils as json

View File

@ -19,8 +19,8 @@ resource classes. For RBAC tests of these classes, see the
'resources_policy_test.py' module. 'resources_policy_test.py' module.
""" """
import mimetypes import mimetypes
from unittest import mock
import mock
import pecan import pecan
from testtools import testcase from testtools import testcase
import webtest import webtest

View File

@ -18,8 +18,8 @@ For typical-flow business logic tests of these classes, see the
'resources_test.py' module. 'resources_test.py' module.
""" """
import os import os
from unittest import mock
import mock
from webob import exc from webob import exc
from barbican.api.controllers import consumers from barbican.api.controllers import consumers

View File

@ -18,7 +18,8 @@ This test module focuses on typical-flow business logic tests with the
transport key resource classes. transport key resource classes.
""" """
import mock from unittest import mock
import pecan import pecan
from six import moves from six import moves
import webtest import webtest

View File

@ -12,8 +12,9 @@
# implied. # implied.
# 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 fixtures import fixtures
import mock
from barbican.cmd import barbican_manage as manager from barbican.cmd import barbican_manage as manager
from barbican.tests import utils from barbican.tests import utils

View File

@ -12,8 +12,8 @@
# implied. # implied.
# 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
import sys import sys
from unittest import mock
from barbican.cmd import retry_scheduler from barbican.cmd import retry_scheduler
from barbican.cmd import worker from barbican.cmd import worker

View File

@ -13,15 +13,16 @@
# 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 datetime
from unittest import mock
from oslo_db import exception as db_exc
from sqlalchemy.exc import IntegrityError
from barbican.model import clean from barbican.model import clean
from barbican.model import models from barbican.model import models
from barbican.model import repositories as repos from barbican.model import repositories as repos
from barbican.tests import database_utils as utils from barbican.tests import database_utils as utils
from oslo_db import exception as db_exc
from sqlalchemy.exc import IntegrityError
import datetime
import mock
def _create_project(project_name): def _create_project(project_name):

View File

@ -12,7 +12,8 @@
# implied. # implied.
# 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_config import cfg from oslo_config import cfg
import six import six

View File

@ -10,11 +10,12 @@
# 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
import six
import sqlalchemy
from alembic import script as alembic_script from alembic import script as alembic_script
from oslo_config import cfg
import six
import sqlalchemy
from barbican.common import config from barbican.common import config
from barbican.common import exception from barbican.common import exception
@ -24,8 +25,6 @@ from barbican.model import repositories
from barbican.tests import database_utils from barbican.tests import database_utils
from barbican.tests import utils from barbican.tests import utils
from oslo_config import cfg
class WhenCleaningRepositoryPagingParameters(utils.BaseTestCase): class WhenCleaningRepositoryPagingParameters(utils.BaseTestCase):

View File

@ -14,11 +14,11 @@
# limitations under the License. # limitations under the License.
import os import os
from unittest import mock
from cryptography import fernet from cryptography import fernet
from cryptography.hazmat.backends import default_backend from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import serialization from cryptography.hazmat.primitives import serialization
import mock
import six import six
from barbican.model import models from barbican.model import models

View File

@ -11,8 +11,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
import threading import threading
from unittest import mock
from barbican.common import utils as common_utils from barbican.common import utils as common_utils
from barbican.plugin.crypto import base from barbican.plugin.crypto import base

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
import six import six
from barbican.common import exception as ex from barbican.common import exception as ex

View File

@ -11,7 +11,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
import six import six
from barbican.common import exception from barbican.common import exception

View File

@ -12,8 +12,8 @@
# limitations under the License. # limitations under the License.
import datetime import datetime
from unittest import mock
import mock
import testtools import testtools
from barbican.common import utils as common_utils from barbican.common import utils as common_utils

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
import six import six
from barbican.common import utils as common_utils from barbican.common import utils as common_utils

View File

@ -13,9 +13,10 @@
# 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
from castellan.common import exception from castellan.common import exception
from castellan.common.objects import opaque_data from castellan.common.objects import opaque_data
import mock
import barbican.plugin.castellan_secret_store as css import barbican.plugin.castellan_secret_store as css
import barbican.plugin.interface.secret_store as ss import barbican.plugin.interface.secret_store as ss

View File

@ -17,12 +17,11 @@ import base64
import datetime import datetime
import os import os
import tempfile import tempfile
from unittest import mock
from cryptography.hazmat.backends import default_backend from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives.asymmetric import rsa from cryptography.hazmat.primitives.asymmetric import rsa
from cryptography.hazmat.primitives import serialization from cryptography.hazmat.primitives import serialization
import mock
from requests import exceptions as request_exceptions from requests import exceptions as request_exceptions
import testtools import testtools

View File

@ -16,19 +16,17 @@ import base64
import ssl import ssl
import stat import stat
import testtools import testtools
from unittest import mock
import mock
from barbican.plugin.interface import secret_store
from barbican.tests import keys
from barbican.tests import utils
from kmip.core import enums from kmip.core import enums
from kmip.pie import client from kmip.pie import client
from kmip.pie import objects from kmip.pie import objects
from barbican.plugin.interface import secret_store
from barbican.plugin import kmip_secret_store as kss from barbican.plugin import kmip_secret_store as kss
from barbican.plugin.util import translations from barbican.plugin.util import translations
from barbican.tests import keys
from barbican.tests import utils
def get_sample_opaque_secret(): def get_sample_opaque_secret():

View File

@ -13,8 +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 base64 import base64
from unittest import mock
import mock
import testtools import testtools
from barbican.model import models from barbican.model import models

View File

@ -15,11 +15,11 @@
import base64 import base64
import os import os
from unittest import mock
from cryptography.hazmat.backends import default_backend from cryptography.hazmat.backends import default_backend
from cryptography import x509 from cryptography import x509
import fixtures import fixtures
import mock
from OpenSSL import crypto from OpenSSL import crypto
from oslo_config import fixture as oslo_fixture from oslo_config import fixture as oslo_fixture

View File

@ -13,8 +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 base64 import base64
from unittest import mock
import mock
import testtools import testtools
from barbican.common import utils from barbican.common import utils

View File

@ -13,8 +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
import testtools import testtools
from unittest import mock
try: try:
import barbican.plugin.interface.certificate_manager as cm import barbican.plugin.interface.certificate_manager as cm

View File

@ -14,7 +14,8 @@
# limitations under the License. # limitations under the License.
import collections import collections
import mock from unittest import mock
from oslo_utils import uuidutils from oslo_utils import uuidutils
from barbican.common import config from barbican.common import config

View File

@ -12,7 +12,7 @@
# implied. # implied.
# 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 barbican import queue from barbican import queue
from barbican.queue import client from barbican.queue import client

View File

@ -12,11 +12,11 @@
# implied. # implied.
# 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 oslo_utils import uuidutils from unittest import mock
import mock
import oslo_messaging import oslo_messaging
from oslo_service import service from oslo_service import service
from oslo_utils import uuidutils
from barbican.common import config from barbican.common import config
from barbican import queue from barbican import queue

View File

@ -13,9 +13,9 @@
import datetime import datetime
import time import time
from unittest import mock
import eventlet import eventlet
import mock
import oslotest.base as oslotest import oslotest.base as oslotest
from barbican.model import models from barbican.model import models

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 datetime import datetime
import mock from unittest import mock
import six import six
from barbican.model import models from barbican.model import models

View File

@ -15,11 +15,11 @@
import base64 import base64
import datetime import datetime
from unittest import mock
from cryptography.hazmat.backends import default_backend from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives.asymmetric import rsa from cryptography.hazmat.primitives.asymmetric import rsa
from cryptography.hazmat.primitives import serialization from cryptography.hazmat.primitives import serialization
import mock
from OpenSSL import crypto from OpenSSL import crypto
from oslo_utils import encodeutils from oslo_utils import encodeutils

View File

@ -13,7 +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.
import mock from unittest import mock
from oslo_utils import uuidutils
import sqlalchemy import sqlalchemy
from barbican.common import exception from barbican.common import exception
@ -24,7 +26,6 @@ from barbican.plugin.crypto import manager
from barbican.plugin import resources as plugin from barbican.plugin import resources as plugin
from barbican.tasks import keystone_consumer as consumer from barbican.tasks import keystone_consumer as consumer
from barbican.tests import database_utils from barbican.tests import database_utils
from oslo_utils import uuidutils
class InitializeDatabaseMixin(object): class InitializeDatabaseMixin(object):

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

View File

@ -13,9 +13,9 @@
# under the License. # under the License.
import textwrap import textwrap
from unittest import mock
import ddt import ddt
import mock
import pep8 import pep8
from barbican.hacking import checks from barbican.hacking import checks

View File

@ -19,26 +19,23 @@ import os
from os import path from os import path
import time import time
import types import types
from unittest import mock
import mock from OpenSSL import crypto
from oslo_config import cfg from oslo_config import cfg
from oslo_utils import uuidutils from oslo_utils import uuidutils
import oslotest.base as oslotest import oslotest.base as oslotest
from oslotest import createfile from oslotest import createfile
import six import six
from six.moves.urllib import parse from six.moves.urllib import parse
import webtest import webtest
from OpenSSL import crypto
from barbican.api import app from barbican.api import app
from barbican.common import config from barbican.common import config
import barbican.context import barbican.context
from barbican.model import repositories from barbican.model import repositories
from barbican.plugin.crypto import manager as cm from barbican.plugin.crypto import manager as cm
from barbican.plugin.crypto import p11_crypto from barbican.plugin.crypto import p11_crypto
from barbican.plugin.interface import secret_store from barbican.plugin.interface import secret_store
from barbican.plugin import kmip_secret_store as kss from barbican.plugin import kmip_secret_store as kss
from barbican.tests import database_utils from barbican.tests import database_utils

View File

@ -52,7 +52,6 @@ logutils==0.3.5
Mako==1.0.7 Mako==1.0.7
MarkupSafe==1.0 MarkupSafe==1.0
mccabe==0.2.1 mccabe==0.2.1
mock==2.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

@ -7,7 +7,6 @@ hacking!=0.13.0,<0.14,>=0.12.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
mock>=2.0.0 # BSD
oslotest>=3.2.0 # Apache-2.0 oslotest>=3.2.0 # Apache-2.0
pykmip>=0.7.0 # Apache 2.0 License pykmip>=0.7.0 # Apache 2.0 License
stestr>=2.0.0 # Apache-2.0 stestr>=2.0.0 # Apache-2.0