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: I2de669d8e89b8daeb7ee5405ffab35af6307c40b
This commit is contained in:
Ivan Kolodyazhny 2020-03-26 19:45:37 +02:00
parent ddc52a7405
commit 14e779bbac
72 changed files with 103 additions and 101 deletions

View File

@ -11,10 +11,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 textwrap
from unittest import mock
import mock
import pycodestyle
from horizon.hacking import checks

View File

@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import mock
from unittest import mock
from django.core.management import call_command
from django.core.management import CommandError

View File

@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import mock
from unittest import mock
from django.core.management import call_command
from django.core.management import CommandError

View File

@ -14,8 +14,8 @@
# under the License.
import datetime
from unittest import mock
import mock
import pytz
from django.conf import settings

View File

@ -13,8 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from mock import patch
from unittest import mock
from unittest.mock import patch
from django.conf import settings
from django.core.exceptions import MiddlewareNotUsed

View File

@ -16,6 +16,7 @@
# under the License.
import unittest
from unittest import mock
import uuid
from django import forms
@ -25,7 +26,6 @@ from django.template import defaultfilters
from django.test.utils import override_settings
from django.urls import reverse
from django.utils.translation import ungettext_lazy
import mock
from horizon import exceptions
from horizon import tables

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 django import forms
from django import http

View File

@ -47,7 +47,6 @@ kombu==4.0.0
linecache2==1.0.0
MarkupSafe==1.0
mccabe==0.2.1
mock==2.0.0
monotonic==0.6
msgpack-python==0.4.0
munch==2.1.0

View File

@ -11,6 +11,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from unittest import mock
import uuid
from django.conf import settings
@ -23,7 +24,7 @@ from keystoneauth1.identity import v3 as v3_auth
from keystoneauth1 import session
from keystoneclient.v3 import client as client_v3
from keystoneclient.v3 import projects
import mock
from openstack_auth.plugin import password
from openstack_auth.tests import data_v3

View File

@ -11,9 +11,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from unittest import mock
from django import http
from django import test
import mock
from openstack_auth import policy
from openstack_auth import user

View File

@ -11,8 +11,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from unittest import mock
from django import test
import mock
from openstack_auth import user

View File

@ -10,7 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from django.urls import reverse
from django.utils import html

View File

@ -12,9 +12,9 @@
# License for the specific language governing permissions and limitations
# under the License.
from django.urls import reverse
from unittest import mock
import mock
from django.urls import reverse
from openstack_dashboard import api
from openstack_dashboard.test import helpers as test

View File

@ -10,10 +10,11 @@
# License for the specific language governing permissions and limitations
# under the License.
from unittest import mock
import django
from django.conf import settings
from django.urls import reverse
import mock
from novaclient.v2 import flavors
from openstack_dashboard import api

View File

@ -12,9 +12,9 @@
# License for the specific language governing permissions and limitations
# under the License.
from django.urls import reverse
from unittest import mock
import mock
from django.urls import reverse
from openstack_dashboard import api
from openstack_dashboard.test import helpers as test

View File

@ -12,12 +12,12 @@
# License for the specific language governing permissions and limitations
# under the License.
from unittest import mock
from django.conf import settings
from django.test.utils import override_settings
from django.urls import reverse
import mock
from openstack_dashboard import api
from openstack_dashboard.test import helpers as test

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 django.urls import reverse

View File

@ -13,11 +13,9 @@
# under the License.
from collections import OrderedDict
from unittest import mock
import uuid
import mock
from django.conf import settings
from django.test import override_settings
from django.urls import reverse

View File

@ -15,11 +15,10 @@
import json
from unittest import mock
from django.urls import reverse
import mock
from openstack_dashboard import api
from openstack_dashboard.dashboards.admin.metadata_defs \
import constants

View File

@ -13,9 +13,9 @@
# License for the specific language governing permissions and limitations
# under the License.
from django.urls import reverse
from unittest import mock
import mock
from django.urls import reverse
from openstack_dashboard import api
from openstack_dashboard.test import helpers as test

View File

@ -14,12 +14,11 @@
# under the License.
import collections
from unittest import mock
from django.test.utils import override_settings
from django.urls import reverse
import mock
from horizon.workflows import views
from openstack_dashboard import api

View File

@ -14,9 +14,9 @@
# under the License.
import collections
from unittest import mock
from django.urls import reverse
import mock
from horizon.workflows import views

View File

@ -13,12 +13,11 @@
# under the License.
import collections
from unittest import mock
from django.urls import reverse
from django.utils.http import urlunquote
import mock
from horizon import forms
from openstack_dashboard import api

View File

@ -17,14 +17,13 @@
# under the License.
import datetime
from unittest import mock
from django.test.utils import override_settings
from django.urls import reverse
from django.utils import encoding
from django.utils import timezone
import mock
from horizon.templatetags import sizeformat
from openstack_dashboard import api

View File

@ -11,8 +11,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.
from unittest import mock
from django.urls import reverse
import mock
from openstack_dashboard import api
from openstack_dashboard.test import helpers as test

View File

@ -12,9 +12,9 @@
# License for the specific language governing permissions and limitations
# under the License.
from django.urls import reverse
from unittest import mock
import mock
from django.urls import reverse
from openstack_dashboard import api
from openstack_dashboard.dashboards.project.routers import tests as r_test

View File

@ -10,11 +10,12 @@
# License for the specific language governing permissions and limitations
# under the License.
from unittest import mock
from django.conf import settings
from django.test.utils import override_settings
from django.urls import reverse
from django.utils.http import urlunquote
import mock
from openstack_dashboard.api import cinder
from openstack_dashboard.api import keystone

View File

@ -12,8 +12,9 @@
# License for the specific language governing permissions and limitations
# under the License.
from unittest import mock
from django.urls import reverse
import mock
from openstack_dashboard import api

View File

@ -12,9 +12,9 @@
# License for the specific language governing permissions and limitations
# under the License.
from django.urls import reverse
from unittest import mock
import mock
from django.urls import reverse
from openstack_dashboard import api
from openstack_dashboard.test import helpers as test

View File

@ -10,9 +10,9 @@
# License for the specific language governing permissions and limitations
# under the License.
from django.urls import reverse
from unittest import mock
import mock
from django.urls import reverse
from openstack_dashboard import api
from openstack_dashboard.dashboards.admin.volume_types.qos_specs \

View File

@ -10,8 +10,9 @@
# License for the specific language governing permissions and limitations
# under the License.
from unittest import mock
from django.urls import reverse
import mock
from horizon import exceptions

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 django.urls import reverse

View File

@ -12,9 +12,9 @@
# License for the specific language governing permissions and limitations
# under the License.
from django.urls import reverse
from unittest import mock
import mock
from django.urls import reverse
from horizon.workflows import views

View File

@ -12,9 +12,9 @@
# License for the specific language governing permissions and limitations
# under the License.
from django.urls import reverse
from unittest import mock
import mock
from django.urls import reverse
from openstack_dashboard import api
from openstack_dashboard.test import helpers as test

View File

@ -14,14 +14,13 @@
import datetime
import logging
from unittest import mock
from django.test import tag
from django.test.utils import override_settings
from django.urls import reverse
from django.utils import timezone
import mock
from horizon.workflows import views
from openstack_dashboard import api

View File

@ -12,9 +12,9 @@
# License for the specific language governing permissions and limitations
# under the License.
from django.urls import reverse
from unittest import mock
import mock
from django.urls import reverse
from openstack_dashboard import api
from openstack_dashboard.test import helpers as test

View File

@ -17,12 +17,11 @@
# under the License.
from socket import timeout as socket_timeout
from unittest import mock
from django.test.utils import override_settings
from django.urls import reverse
import mock
from openstack_dashboard import api
from openstack_dashboard.dashboards.identity.users import tabs
from openstack_dashboard.test import helpers as test

View File

@ -17,11 +17,11 @@
# License for the specific language governing permissions and limitations
# under the License.
from unittest import mock
from django.urls import reverse
from django.utils.http import urlencode
import mock
from openstack_dashboard import api
from openstack_dashboard.test import helpers as test
from openstack_dashboard.usage import quotas

View File

@ -17,14 +17,13 @@
# under the License.
import tempfile
from unittest import mock
from django.conf import settings
from django.core.files.uploadedfile import InMemoryUploadedFile
from django.test.utils import override_settings
from django.urls import reverse
import mock
from horizon import tables as horizon_tables
from openstack_dashboard import api
from openstack_dashboard.test import helpers as test

View File

@ -16,9 +16,9 @@
# License for the specific language governing permissions and limitations
# under the License.
from django.urls import reverse
from unittest import mock
import mock
from django.urls import reverse
from openstack_dashboard import api
from openstack_dashboard.test import helpers as test

View File

@ -21,11 +21,10 @@ import os
from socket import timeout as socket_timeout
import tempfile
import unittest
from unittest import mock
from django.urls import reverse
import mock
from horizon import exceptions
from openstack_dashboard import api

View File

@ -20,6 +20,7 @@ import collections
import json
import logging
import sys
from unittest import mock
from django.conf import settings
from django.forms import widgets
@ -28,7 +29,6 @@ import django.test
from django.test.utils import override_settings
from django.urls import reverse
from django.utils.http import urlencode
import mock
from novaclient import api_versions
from horizon import exceptions

View File

@ -16,10 +16,10 @@
# License for the specific language governing permissions and limitations
# under the License.
from unittest import mock
from urllib import parse
from django.urls import reverse
import mock
from openstack_dashboard import api
from openstack_dashboard.dashboards.project.key_pairs.forms \

View File

@ -12,10 +12,11 @@
# License for the specific language governing permissions and limitations
# under the License.
from unittest import mock
import django.test
from django.urls import reverse
import mock
from oslo_serialization import jsonutils
from openstack_dashboard import api

View File

@ -15,12 +15,11 @@
import collections
import copy
from unittest import mock
from django.test.utils import override_settings
from django.urls import reverse
import mock
from openstack_auth import utils as auth_utils
from horizon.workflows import views

View File

@ -13,8 +13,9 @@
# License for the specific language governing permissions and limitations
# under the License.
from unittest import mock
from django.urls import reverse
import mock
from horizon.workflows import views

View File

@ -13,11 +13,11 @@
# under the License.
import collections
from unittest import mock
from django.urls import reverse
from django.utils.html import escape
from django.utils.http import urlunquote
import mock
from horizon.workflows import views

View File

@ -18,13 +18,12 @@
import datetime
import logging
from unittest import mock
from django.test.utils import override_settings
from django.urls import reverse
from django.utils import timezone
import mock
from openstack_dashboard import api
from openstack_dashboard.test import helpers as test
from openstack_dashboard import usage

View File

@ -11,12 +11,12 @@
# 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 copy
from unittest import mock
from django.urls import reverse
import mock
from openstack_dashboard import api
from openstack_dashboard.test import helpers as test
from openstack_dashboard.usage import quotas

View File

@ -16,7 +16,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from django.conf import settings
from django.urls import reverse

View File

@ -16,11 +16,12 @@
# License for the specific language governing permissions and limitations
# under the License.
from unittest import mock
from django.conf import settings
from django.test.utils import override_settings
from django.urls import reverse
from django.utils.http import urlunquote
import mock
from openstack_dashboard import api
from openstack_dashboard.dashboards.project.snapshots \

View File

@ -10,8 +10,9 @@
# License for the specific language governing permissions and limitations
# under the License.
from unittest import mock
from django.urls import reverse
import mock
from openstack_dashboard.api import cinder
from openstack_dashboard.test import helpers as test

View File

@ -10,9 +10,10 @@
# License for the specific language governing permissions and limitations
# under the License.
from unittest import mock
from django.urls import reverse
from django.utils.http import urlunquote
import mock
from openstack_dashboard.api import cinder
from openstack_dashboard.test import helpers as test

View File

@ -13,8 +13,7 @@
# under the License.
import copy
import mock
from unittest import mock
from django.conf import settings
from django.forms import widgets

View File

@ -12,13 +12,13 @@
# License for the specific language governing permissions and limitations
# under the License.
from unittest import mock
from urllib.parse import urlsplit
from django.conf import settings
from django import http
from django.urls import reverse
import mock
from openstack_dashboard import api
from openstack_dashboard.test import helpers as test

View File

@ -21,6 +21,7 @@ import importlib
import logging
import os
import traceback
from unittest import mock
from django.conf import settings
from django.contrib.messages.storage import default_storage
@ -30,7 +31,6 @@ from django.test import tag
from django import urls
from django.utils import http
import mock
from openstack_auth import user
from openstack_auth import utils
from requests.packages.urllib3.connection import HTTPConnection

View File

@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import mock
from unittest import mock
from openstack_dashboard import api
from openstack_dashboard.test import helpers as test

View File

@ -12,7 +12,7 @@
# WITHOUT 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 openstack_dashboard import api
from openstack_dashboard.api.rest import glance

View File

@ -12,8 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from unittest import mock
from django.conf import settings
import mock
from oslo_serialization import jsonutils
from openstack_dashboard import api

View File

@ -13,8 +13,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from unittest import mock
from django.http import request as django_request
import mock
from openstack_dashboard import api
from openstack_dashboard.api import base

View File

@ -14,10 +14,10 @@
import json
from json import loads as to_json
from unittest import mock
import uuid
from django.conf import settings
import mock
from openstack_dashboard import api
from openstack_dashboard.api.base import Quota

View File

@ -11,7 +11,7 @@
# WITHOUT 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 openstack_dashboard import api
from openstack_dashboard.api.rest import swift

View File

@ -12,11 +12,12 @@
# License for the specific language governing permissions and limitations
# under the License.
from unittest import mock
from django.conf import settings
from django.test.utils import override_settings
import cinderclient as cinder_client
import mock
from openstack_dashboard import api
from openstack_dashboard.test import helpers as test

View File

@ -16,9 +16,10 @@
# License for the specific language governing permissions and limitations
# under the License.
from unittest import mock
from django.conf import settings
from django.test.utils import override_settings
import mock
from openstack_dashboard import api
from openstack_dashboard.api import base

View File

@ -17,8 +17,8 @@
# under the License.
from __future__ import absolute_import
from unittest import mock
import mock
from openstack_dashboard import api
from openstack_dashboard.test import helpers as test

View File

@ -11,8 +11,8 @@
# under the License.
import unittest
from unittest import mock
import mock
from openstack_dashboard.api import microversions

View File

@ -13,8 +13,8 @@
# under the License.
import collections
from unittest import mock
import mock
import netaddr
from django.test.utils import override_settings

View File

@ -12,8 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import copy
from unittest import mock
import mock
import netaddr
from neutronclient.common import exceptions as neutron_exc
from oslo_utils import uuidutils

View File

@ -18,11 +18,11 @@
# under the License.
from __future__ import absolute_import
from unittest import mock
from django.conf import settings
from django.test.utils import override_settings
import mock
from novaclient import api_versions
from novaclient import exceptions as nova_exceptions
from novaclient.v2 import flavor_access as nova_flavor_access

View File

@ -17,8 +17,7 @@
# under the License.
from __future__ import absolute_import
import mock
from unittest import mock
from horizon import exceptions

View File

@ -20,10 +20,10 @@
from __future__ import absolute_import
import collections
from unittest import mock
from django.test.utils import override_settings
from django.utils.translation import ugettext_lazy as _
import mock
from horizon import exceptions
from openstack_dashboard import api

View File

@ -13,7 +13,6 @@ astroid==2.1.0 # LGPLv2.1
bandit!=1.6.0,>=1.4.0 # Apache-2.0
coverage!=4.4,>=4.0 # Apache-2.0
flake8-import-order==0.12 # LGPLv3
mock>=2.0.0 # BSD
nodeenv>=0.9.4 # BSD
python-memcached>=1.59 # PSF
pylint==2.2.2 # GPLv2