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):
if (not isinstance(option_label, (six.string_types, Promise)) and
callable(self.transform)):
option_label = self.transform(option_label)
option_label = self.transform(option_label)
return html.conditional_escape(force_text(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)
def test_template_name_change_based_on_ajax_request(self):
view = self._prepare_view(
forms.views.ModalFormView,
dict(HTTP_X_REQUESTED_WITH='XMLHttpRequest'))
self.assertEqual('_' + view.template_name,
view.get_template_names())
view = self._prepare_view(
forms.views.ModalFormView,
dict(HTTP_X_REQUESTED_WITH='XMLHttpRequest'))
self.assertEqual('_' + view.template_name,
view.get_template_names())
view = self._prepare_view(forms.views.ModalFormView, {})
self.assertEqual(view.template_name, view.get_template_names())
view = self._prepare_view(forms.views.ModalFormView, {})
self.assertEqual(view.template_name, view.get_template_names())
class TestForm(forms.SelfHandlingForm):

View File

@ -15,7 +15,7 @@
import textwrap
import mock
import pep8
import pycodestyle
from horizon.hacking import checks
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
# installed.
@mock.patch('pep8._checks',
@mock.patch('pycodestyle._checks',
{'physical_line': {}, 'logical_line': {}, 'tree': {}})
def _run_check(self, code, checker, filename=None):
pep8.register_check(checker)
pycodestyle.register_check(checker)
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.report._deferred_print.sort()
return checker.report._deferred_print

View File

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

View File

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

View File

@ -24,4 +24,4 @@ class OverviewTab(volume_groups_tabs.OverviewTab):
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):
_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",
"confirm_password")
CHANGE_PASSWORD_FORM_FIELDS = ("current_password", "new_password",
"confirm_password")
@property
def password_form(self):
src_elem = self._get_element(*self._password_form_locator)
return forms.FormRegion(
self.driver, self.conf, src_elem=src_elem,
field_mappings=self.CHANGE_PASSWORD_FORM_FIELDS)
@property
def password_form(self):
src_elem = self._get_element(*self._password_form_locator)
return forms.FormRegion(
self.driver, self.conf, src_elem=src_elem,
field_mappings=self.CHANGE_PASSWORD_FORM_FIELDS)
def change_password(self, current, new):
self.password_form.current_password.text = current
self.password_form.new_password.text = new
self.password_form.confirm_password.text = new
self.password_form.submit()
# NOTE(tsufiev): try to apply the same fix as Tempest did for the
# issue of Keystone Fernet tokens lacking sub-second precision
# (in which case it's possible to log in the same second that
# token was revoked due to password change), see bug 1473567
time.sleep(1)
def change_password(self, current, new):
self.password_form.current_password.text = current
self.password_form.new_password.text = new
self.password_form.confirm_password.text = new
self.password_form.submit()
# NOTE(tsufiev): try to apply the same fix as Tempest did for the
# issue of Keystone Fernet tokens lacking sub-second precision
# (in which case it's possible to log in the same second that
# token was revoked due to password change), see bug 1473567
time.sleep(1)
def reset_to_default_password(self, current):
if self.topbar.user.text == self.conf.identity.admin_username:
return self.change_password(current,
self.conf.identity.admin_password)
else:
return self.change_password(current,
self.conf.identity.password)
def reset_to_default_password(self, current):
if self.topbar.user.text == self.conf.identity.admin_username:
return self.change_password(current,
self.conf.identity.admin_password)
else:
return self.change_password(current,
self.conf.identity.password)