Fix gate failures by a new pycodestyle

pycodestyle 2.5.0 introduces E117 over-indented.
This commit fixes E117 errors.

pycodestyle 2.5.0 also drops pep8.py. As a result,
horizon/test/unit/hacking/test_checks.py starts to fail.
The equivalent elements are provided by pycodestyle.py,
so we can consume pycodestyle instead of pep8 module.

Change-Id: Ib103998f42ce7c901a10669b771a898783ca1a92
This commit is contained in:
Akihiro Motoki 2019-01-30 17:02:20 +09:00
parent 65545fb159
commit b06657b07d
7 changed files with 48 additions and 48 deletions

View File

@ -288,7 +288,7 @@ class SelectWidget(widgets.Widget):
def transform_option_label(self, option_label): def transform_option_label(self, option_label):
if (not isinstance(option_label, (six.string_types, Promise)) and if (not isinstance(option_label, (six.string_types, Promise)) and
callable(self.transform)): callable(self.transform)):
option_label = self.transform(option_label) option_label = self.transform(option_label)
return html.conditional_escape(force_text(option_label)) return html.conditional_escape(force_text(option_label))
def transform_option_html_attrs(self, option_label): def transform_option_html_attrs(self, option_label):

View File

@ -58,14 +58,14 @@ class FormMixinTests(test.TestCase):
self.assertNotIn('add_to_field', context) self.assertNotIn('add_to_field', context)
def test_template_name_change_based_on_ajax_request(self): def test_template_name_change_based_on_ajax_request(self):
view = self._prepare_view( view = self._prepare_view(
forms.views.ModalFormView, forms.views.ModalFormView,
dict(HTTP_X_REQUESTED_WITH='XMLHttpRequest')) dict(HTTP_X_REQUESTED_WITH='XMLHttpRequest'))
self.assertEqual('_' + view.template_name, self.assertEqual('_' + view.template_name,
view.get_template_names()) view.get_template_names())
view = self._prepare_view(forms.views.ModalFormView, {}) view = self._prepare_view(forms.views.ModalFormView, {})
self.assertEqual(view.template_name, view.get_template_names()) self.assertEqual(view.template_name, view.get_template_names())
class TestForm(forms.SelfHandlingForm): class TestForm(forms.SelfHandlingForm):

View File

@ -15,7 +15,7 @@
import textwrap import textwrap
import mock import mock
import pep8 import pycodestyle
from horizon.hacking import checks from horizon.hacking import checks
from horizon.test import helpers from horizon.test import helpers
@ -80,14 +80,14 @@ class HackingTestCase(helpers.TestCase):
# We are patching pep8 so that only the check under test is actually # We are patching pep8 so that only the check under test is actually
# installed. # installed.
@mock.patch('pep8._checks', @mock.patch('pycodestyle._checks',
{'physical_line': {}, 'logical_line': {}, 'tree': {}}) {'physical_line': {}, 'logical_line': {}, 'tree': {}})
def _run_check(self, code, checker, filename=None): def _run_check(self, code, checker, filename=None):
pep8.register_check(checker) pycodestyle.register_check(checker)
lines = textwrap.dedent(code).strip().splitlines(True) lines = textwrap.dedent(code).strip().splitlines(True)
checker = pep8.Checker(filename=filename, lines=lines) checker = pycodestyle.Checker(filename=filename, lines=lines)
checker.check_all() checker.check_all()
checker.report._deferred_print.sort() checker.report._deferred_print.sort()
return checker.report._deferred_print return checker.report._deferred_print

View File

@ -73,14 +73,14 @@ class AngularGettextHTMLParser(html_parser.HTMLParser):
self.line = self.getpos()[0] self.line = self.getpos()[0]
if tag == 'translate' or \ if tag == 'translate' or \
(attrs and 'translate' in [attr[0] for attr in attrs]): (attrs and 'translate' in [attr[0] for attr in attrs]):
self.in_translate = True self.in_translate = True
self.plural_form = '' self.plural_form = ''
for attr, value in attrs: for attr, value in attrs:
if attr == 'translate-plural': if attr == 'translate-plural':
self.plural = True self.plural = True
self.plural_form = value self.plural_form = value
if attr == 'translate-comment': if attr == 'translate-comment':
self.comments.append(value) self.comments.append(value)
elif self.in_translate: elif self.in_translate:
s = tag s = tag
if attrs: if attrs:

View File

@ -817,7 +817,7 @@ def get_project_users_roles(request, project):
# filter by project_id # filter by project_id
if ('project' in role_assignment.scope and if ('project' in role_assignment.scope and
role_assignment.scope['project']['id'] == project): role_assignment.scope['project']['id'] == project):
users_roles[user_id].append(role_id) users_roles[user_id].append(role_id)
return users_roles return users_roles

View File

@ -24,4 +24,4 @@ class OverviewTab(volume_groups_tabs.OverviewTab):
class GroupsDetailTabs(volume_groups_tabs.GroupsDetailTabs): class GroupsDetailTabs(volume_groups_tabs.GroupsDetailTabs):
tabs = (OverviewTab,) tabs = (OverviewTab,)

View File

@ -20,33 +20,33 @@ from openstack_dashboard.test.integration_tests.regions import forms
class ChangepasswordPage(basepage.BaseNavigationPage): class ChangepasswordPage(basepage.BaseNavigationPage):
_password_form_locator = (by.By.ID, 'change_password_modal') _password_form_locator = (by.By.ID, 'change_password_modal')
CHANGE_PASSWORD_FORM_FIELDS = ("current_password", "new_password", CHANGE_PASSWORD_FORM_FIELDS = ("current_password", "new_password",
"confirm_password") "confirm_password")
@property @property
def password_form(self): def password_form(self):
src_elem = self._get_element(*self._password_form_locator) src_elem = self._get_element(*self._password_form_locator)
return forms.FormRegion( return forms.FormRegion(
self.driver, self.conf, src_elem=src_elem, self.driver, self.conf, src_elem=src_elem,
field_mappings=self.CHANGE_PASSWORD_FORM_FIELDS) field_mappings=self.CHANGE_PASSWORD_FORM_FIELDS)
def change_password(self, current, new): def change_password(self, current, new):
self.password_form.current_password.text = current self.password_form.current_password.text = current
self.password_form.new_password.text = new self.password_form.new_password.text = new
self.password_form.confirm_password.text = new self.password_form.confirm_password.text = new
self.password_form.submit() self.password_form.submit()
# NOTE(tsufiev): try to apply the same fix as Tempest did for the # NOTE(tsufiev): try to apply the same fix as Tempest did for the
# issue of Keystone Fernet tokens lacking sub-second precision # issue of Keystone Fernet tokens lacking sub-second precision
# (in which case it's possible to log in the same second that # (in which case it's possible to log in the same second that
# token was revoked due to password change), see bug 1473567 # token was revoked due to password change), see bug 1473567
time.sleep(1) time.sleep(1)
def reset_to_default_password(self, current): def reset_to_default_password(self, current):
if self.topbar.user.text == self.conf.identity.admin_username: if self.topbar.user.text == self.conf.identity.admin_username:
return self.change_password(current, return self.change_password(current,
self.conf.identity.admin_password) self.conf.identity.admin_password)
else: else:
return self.change_password(current, return self.change_password(current,
self.conf.identity.password) self.conf.identity.password)