From bd68639408372c938766bc53c6cc305b8a9743ce Mon Sep 17 00:00:00 2001 From: Akihiro Motoki Date: Thu, 9 Apr 2020 04:34:55 +0900 Subject: [PATCH] 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 --- heat_dashboard/test/helpers.py | 2 +- heat_dashboard/test/tests/api/test_heat.py | 3 +-- heat_dashboard/test/tests/api/test_heat_rest.py | 3 +-- heat_dashboard/test/tests/content/test_stacks.py | 2 +- lower-constraints.txt | 7 +++---- requirements.txt | 2 +- test-requirements.txt | 1 - tox.ini | 5 +++-- 8 files changed, 11 insertions(+), 14 deletions(-) diff --git a/heat_dashboard/test/helpers.py b/heat_dashboard/test/helpers.py index d80feb2..8b45aa8 100644 --- a/heat_dashboard/test/helpers.py +++ b/heat_dashboard/test/helpers.py @@ -20,6 +20,7 @@ from importlib import import_module import os import traceback import unittest +from unittest import mock import django from django.conf import settings @@ -30,7 +31,6 @@ from django.utils import http from heatclient import client as heat_client from keystoneclient.v2_0 import client as keystone_client -import mock from neutronclient.v2_0 import client as neutron_client from openstack_auth import user from openstack_auth import utils diff --git a/heat_dashboard/test/tests/api/test_heat.py b/heat_dashboard/test/tests/api/test_heat.py index 9375b4f..9e77a1e 100644 --- a/heat_dashboard/test/tests/api/test_heat.py +++ b/heat_dashboard/test/tests/api/test_heat.py @@ -11,8 +11,7 @@ # under the License. import io - -import mock +from unittest import mock from django.conf import settings from django.test.utils import override_settings diff --git a/heat_dashboard/test/tests/api/test_heat_rest.py b/heat_dashboard/test/tests/api/test_heat_rest.py index bc89d7c..8eda8d9 100644 --- a/heat_dashboard/test/tests/api/test_heat_rest.py +++ b/heat_dashboard/test/tests/api/test_heat_rest.py @@ -12,8 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. import json - -import mock +from unittest import mock from heat_dashboard.api.rest import heat from heat_dashboard.test import helpers as test diff --git a/heat_dashboard/test/tests/content/test_stacks.py b/heat_dashboard/test/tests/content/test_stacks.py index ae07161..8a12ce7 100644 --- a/heat_dashboard/test/tests/content/test_stacks.py +++ b/heat_dashboard/test/tests/content/test_stacks.py @@ -12,13 +12,13 @@ import json import re +from unittest import mock from django.conf import settings from django.core import exceptions from django.test.utils import override_settings from django.urls import reverse from django.utils import html -import mock from heatclient.common import template_format as hc_format from openstack_dashboard import api as dashboard_api diff --git a/lower-constraints.txt b/lower-constraints.txt index 96d4b42..92ef38c 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -31,7 +31,7 @@ flake8-import-order==0.12 futurist==1.2.0 greenlet==0.4.10 hacking==1.1.0 -horizon==17.1.0 +horizon==18.3.1 idna==2.6 iso8601==0.1.11 Jinja2==2.10 @@ -44,7 +44,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 @@ -84,7 +83,7 @@ pymongo==3.0.2 pyOpenSSL==17.1.0 pyparsing==2.1.0 pyperclip==1.5.27 -pyScss==1.3.4 +pyScss==1.3.7 python-cinderclient==5.0.0 python-dateutil==2.5.3 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.TableSorter==2.14.5.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-Rickshaw==1.5.0.0 XStatic-roboto-fontface==0.5.0.0 diff --git a/requirements.txt b/requirements.txt index aff7b71..b737e47 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 # 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-vis>=4.16.0.0 # MIT diff --git a/test-requirements.txt b/test-requirements.txt index 5043ae3..20fbe93 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -12,7 +12,6 @@ hacking>=1.1.0,<1.2.0 # Apache-2.0 coverage!=4.4,>=4.0 # Apache-2.0 doc8>=0.6.0 # Apache-2.0 flake8-import-order==0.12 # LGPLv3 -mock>=2.0.0 # BSD nodeenv>=0.9.4 # BSD testtools>=2.2.0 # MIT diff --git a/tox.ini b/tox.ini index 0778c94..943de4d 100644 --- a/tox.ini +++ b/tox.ini @@ -64,8 +64,9 @@ deps = -c{env:UPPER_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/ -r{toxinidir}/doc/requirements.txt commands = sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html -[hacking] -local-check-factory = horizon.hacking.checks.factory +# Temporary disabled to pass the pep8 job +# [hacking] +# local-check-factory = horizon.hacking.checks.factory [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