From 4052bde7009d142ab9808110fb53498a966b14ef Mon Sep 17 00:00:00 2001 From: Akihiro Motoki Date: Mon, 27 Aug 2018 02:36:16 +0900 Subject: [PATCH] Django 2.0 support Horizon and most horizon plugins support Django 2.0 in Rocky. This commit focuses on passing the unit tests with Django 2.0. It would be nice if masakari-dashboard team tests it in real environments. Replace django.core.urlresolves with django.urls (In Django 2.0) The django.core.urlresolvers module is removed in favor of its new location, django.urls. It was deprecated in Django 1.10: https://docs.djangoproject.com/en/2.0/releases/1.10/#id3 Drops older Django unit tests from tox.ini as horizon dropped Django <=1.10 support in Rocky. Change-Id: I67907a2460f8472e5a6222210d74b3eed71be064 --- masakaridashboard/hosts/forms.py | 2 +- masakaridashboard/hosts/tables.py | 2 +- masakaridashboard/hosts/tests.py | 2 +- masakaridashboard/hosts/views.py | 4 ++-- masakaridashboard/notifications/tests.py | 2 +- masakaridashboard/notifications/views.py | 2 +- masakaridashboard/segments/forms.py | 2 +- masakaridashboard/segments/tables.py | 2 +- masakaridashboard/segments/tests.py | 2 +- masakaridashboard/segments/views.py | 4 ++-- tox.ini | 8 +------- 11 files changed, 13 insertions(+), 19 deletions(-) diff --git a/masakaridashboard/hosts/forms.py b/masakaridashboard/hosts/forms.py index 37ab44a..cdb38f5 100644 --- a/masakaridashboard/hosts/forms.py +++ b/masakaridashboard/hosts/forms.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from django.core.urlresolvers import reverse +from django.urls import reverse from django.utils.translation import ugettext_lazy as _ from horizon import exceptions diff --git a/masakaridashboard/hosts/tables.py b/masakaridashboard/hosts/tables.py index 81e2476..a26c680 100644 --- a/masakaridashboard/hosts/tables.py +++ b/masakaridashboard/hosts/tables.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from django.core.urlresolvers import reverse +from django.urls import reverse from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ungettext_lazy diff --git a/masakaridashboard/hosts/tests.py b/masakaridashboard/hosts/tests.py index 74f4c23..9939eac 100644 --- a/masakaridashboard/hosts/tests.py +++ b/masakaridashboard/hosts/tests.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -from django.core.urlresolvers import reverse +from django.urls import reverse import mock from masakaridashboard.test import helpers as test diff --git a/masakaridashboard/hosts/views.py b/masakaridashboard/hosts/views.py index 2504d74..3191d7a 100644 --- a/masakaridashboard/hosts/views.py +++ b/masakaridashboard/hosts/views.py @@ -13,8 +13,8 @@ # limitations under the License. from django.conf import settings -from django.core.urlresolvers import reverse -from django.core.urlresolvers import reverse_lazy +from django.urls import reverse +from django.urls import reverse_lazy from django.utils.translation import ugettext_lazy as _ from horizon import exceptions diff --git a/masakaridashboard/notifications/tests.py b/masakaridashboard/notifications/tests.py index b3aa833..359c388 100644 --- a/masakaridashboard/notifications/tests.py +++ b/masakaridashboard/notifications/tests.py @@ -13,8 +13,8 @@ # limitations under the License. from django.conf import settings -from django.core.urlresolvers import reverse from django.test.utils import override_settings +from django.urls import reverse from django.utils.http import urlunquote import mock diff --git a/masakaridashboard/notifications/views.py b/masakaridashboard/notifications/views.py index 53c45d7..d4f3c2d 100644 --- a/masakaridashboard/notifications/views.py +++ b/masakaridashboard/notifications/views.py @@ -13,7 +13,7 @@ # limitations under the License. from django.conf import settings -from django.core.urlresolvers import reverse +from django.urls import reverse from django.utils.translation import ugettext_lazy as _ from horizon import exceptions diff --git a/masakaridashboard/segments/forms.py b/masakaridashboard/segments/forms.py index bbc5bc4..d8ca1b5 100644 --- a/masakaridashboard/segments/forms.py +++ b/masakaridashboard/segments/forms.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -from django.core.urlresolvers import reverse +from django.urls import reverse from django.utils.translation import ugettext_lazy as _ from horizon import exceptions diff --git a/masakaridashboard/segments/tables.py b/masakaridashboard/segments/tables.py index 21074ec..603ff10 100644 --- a/masakaridashboard/segments/tables.py +++ b/masakaridashboard/segments/tables.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -from django.core.urlresolvers import reverse +from django.urls import reverse from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ungettext_lazy diff --git a/masakaridashboard/segments/tests.py b/masakaridashboard/segments/tests.py index bbee210..528301d 100644 --- a/masakaridashboard/segments/tests.py +++ b/masakaridashboard/segments/tests.py @@ -16,8 +16,8 @@ import mock from django.conf import settings -from django.core.urlresolvers import reverse from django.test.utils import override_settings +from django.urls import reverse from django.utils.http import urlunquote from openstack_dashboard.test import helpers diff --git a/masakaridashboard/segments/views.py b/masakaridashboard/segments/views.py index bf60c1f..11a3385 100644 --- a/masakaridashboard/segments/views.py +++ b/masakaridashboard/segments/views.py @@ -14,8 +14,8 @@ # under the License. from django.conf import settings -from django.core.urlresolvers import reverse -from django.core.urlresolvers import reverse_lazy +from django.urls import reverse +from django.urls import reverse_lazy from django.utils.translation import ugettext_lazy as _ from horizon import tables diff --git a/tox.ini b/tox.ini index 64a9c2f..2f2d05e 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py35,py27,py27dj18,pep8 +envlist = py35,py27,pep8 minversion = 2.0 skipsdist = True @@ -32,12 +32,6 @@ commands = coverage xml --omit '.tox/cover/*' -o 'cover/coverage.xml' coverage html --omit '.tox/cover/*' -d 'cover/htmlcov' -[testenv:py27dj18] -basepython = python2.7 -commands = - pip install django>=1.8,<1.9 - {[testenv]commands} - [testenv:eslint] whitelist_externals = npm commands =