Use unittest.mock instead of third party mock

horizon recently switched from the third-party mock to unittest.mock.
This breaks heat-dashboard unit tests somehow.
We no longer support py27 and we can use the standard library
unittest.mock module. Rather than investigating the cause of
the failure, it would be nice to switch to unittest.mock.

horizon dependency is updated to 18.3.1 as unittest.mock is used
since 18.3.0 and 18.3.0 has an issue that it always requires pytest.
lower-constraints is updated to match horizon requirements.

hacking local-check-factory is disabled temporarily due to
the incompatibility with hacking 2.0 or later.
https://review.opendev.org/#/c/715690/ will recover it.

Change-Id: I517d6d7d36410c64bf48ad958b3e2115725a6491
This commit is contained in:
Akihiro Motoki 2020-04-09 04:34:55 +09:00
parent 7842190851
commit bd68639408
8 changed files with 11 additions and 14 deletions

View File

@ -20,6 +20,7 @@ from importlib import import_module
import os import os
import traceback import traceback
import unittest import unittest
from unittest import mock
import django import django
from django.conf import settings from django.conf import settings
@ -30,7 +31,6 @@ from django.utils import http
from heatclient import client as heat_client from heatclient import client as heat_client
from keystoneclient.v2_0 import client as keystone_client from keystoneclient.v2_0 import client as keystone_client
import mock
from neutronclient.v2_0 import client as neutron_client from neutronclient.v2_0 import client as neutron_client
from openstack_auth import user from openstack_auth import user
from openstack_auth import utils from openstack_auth import utils

View File

@ -11,8 +11,7 @@
# under the License. # under the License.
import io import io
from unittest import mock
import mock
from django.conf import settings from django.conf import settings
from django.test.utils import override_settings from django.test.utils import override_settings

View File

@ -12,8 +12,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 json import json
from unittest import mock
import mock
from heat_dashboard.api.rest import heat from heat_dashboard.api.rest import heat
from heat_dashboard.test import helpers as test from heat_dashboard.test import helpers as test

View File

@ -12,13 +12,13 @@
import json import json
import re import re
from unittest import mock
from django.conf import settings from django.conf import settings
from django.core import exceptions from django.core import exceptions
from django.test.utils import override_settings from django.test.utils import override_settings
from django.urls import reverse from django.urls import reverse
from django.utils import html from django.utils import html
import mock
from heatclient.common import template_format as hc_format from heatclient.common import template_format as hc_format
from openstack_dashboard import api as dashboard_api from openstack_dashboard import api as dashboard_api

View File

@ -31,7 +31,7 @@ flake8-import-order==0.12
futurist==1.2.0 futurist==1.2.0
greenlet==0.4.10 greenlet==0.4.10
hacking==1.1.0 hacking==1.1.0
horizon==17.1.0 horizon==18.3.1
idna==2.6 idna==2.6
iso8601==0.1.11 iso8601==0.1.11
Jinja2==2.10 Jinja2==2.10
@ -44,7 +44,6 @@ kombu==4.0.0
linecache2==1.0.0 linecache2==1.0.0
MarkupSafe==1.0 MarkupSafe==1.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
munch==2.1.0 munch==2.1.0
@ -84,7 +83,7 @@ pymongo==3.0.2
pyOpenSSL==17.1.0 pyOpenSSL==17.1.0
pyparsing==2.1.0 pyparsing==2.1.0
pyperclip==1.5.27 pyperclip==1.5.27
pyScss==1.3.4 pyScss==1.3.7
python-cinderclient==5.0.0 python-cinderclient==5.0.0
python-dateutil==2.5.3 python-dateutil==2.5.3
python-glanceclient==2.8.0 python-glanceclient==2.8.0
@ -139,7 +138,7 @@ XStatic-jquery-ui==1.10.4.1
XStatic-JQuery.quicksearch==2.0.3.1 XStatic-JQuery.quicksearch==2.0.3.1
XStatic-JQuery.TableSorter==2.14.5.1 XStatic-JQuery.TableSorter==2.14.5.1
XStatic-JSEncrypt==2.3.1.1 XStatic-JSEncrypt==2.3.1.1
XStatic-mdi==1.4.57.0 XStatic-mdi==1.6.50.2
XStatic-objectpath==1.2.1.0 XStatic-objectpath==1.2.1.0
XStatic-Rickshaw==1.5.0.0 XStatic-Rickshaw==1.5.0.0
XStatic-roboto-fontface==0.5.0.0 XStatic-roboto-fontface==0.5.0.0

View File

@ -12,7 +12,7 @@ python-heatclient>=1.10.0 # Apache-2.0
# This will be installed from git in OpenStack CI if the job setting # This will be installed from git in OpenStack CI if the job setting
# required-projects for horizon: # required-projects for horizon:
horizon>=17.1.0 # Apache-2.0 horizon>=18.3.1 # Apache-2.0
xstatic-angular-uuid>=0.0.4.0 # MIT xstatic-angular-uuid>=0.0.4.0 # MIT
xstatic-angular-vis>=4.16.0.0 # MIT xstatic-angular-vis>=4.16.0.0 # MIT

View File

@ -12,7 +12,6 @@ hacking>=1.1.0,<1.2.0 # Apache-2.0
coverage!=4.4,>=4.0 # Apache-2.0 coverage!=4.4,>=4.0 # Apache-2.0
doc8>=0.6.0 # Apache-2.0 doc8>=0.6.0 # Apache-2.0
flake8-import-order==0.12 # LGPLv3 flake8-import-order==0.12 # LGPLv3
mock>=2.0.0 # BSD
nodeenv>=0.9.4 # BSD nodeenv>=0.9.4 # BSD
testtools>=2.2.0 # MIT testtools>=2.2.0 # MIT

View File

@ -64,8 +64,9 @@ deps = -c{env:UPPER_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/
-r{toxinidir}/doc/requirements.txt -r{toxinidir}/doc/requirements.txt
commands = sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html commands = sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html
[hacking] # Temporary disabled to pass the pep8 job
local-check-factory = horizon.hacking.checks.factory # [hacking]
# local-check-factory = horizon.hacking.checks.factory
[flake8] [flake8]
exclude = .venv,.git,.tox,dist,*lib/python*,*egg,build,panel_template,dash_template,local_settings.py,*/local/*,*/test/test_plugins/*,.ropeproject,node_modules,.tmp exclude = .venv,.git,.tox,dist,*lib/python*,*egg,build,panel_template,dash_template,local_settings.py,*/local/*,*/test/test_plugins/*,.ropeproject,node_modules,.tmp