From 4e50f5ebb4e51d6524e0664125695225e82b91e4 Mon Sep 17 00:00:00 2001 From: Paul Belanger Date: Fri, 1 Nov 2013 14:02:41 -0400 Subject: [PATCH] Gate on H4xx docstrings for pep8 In an effort to help horizon more friendly to OpenStack hacking guidelines, we now gate on H40* violations. Change-Id: Id07294543660368d2f7f5ac363710176ab23b874 Signed-off-by: Paul Belanger --- .../dashboards/project/stacks/forms.py | 4 +--- .../dashboards/project/stacks/mappings.py | 4 +--- openstack_dashboard/test/helpers.py | 24 +++++++------------ tox.ini | 3 +-- 4 files changed, 11 insertions(+), 24 deletions(-) diff --git a/openstack_dashboard/dashboards/project/stacks/forms.py b/openstack_dashboard/dashboards/project/stacks/forms.py index f25ec533..0370f961 100644 --- a/openstack_dashboard/dashboards/project/stacks/forms.py +++ b/openstack_dashboard/dashboards/project/stacks/forms.py @@ -29,9 +29,7 @@ LOG = logging.getLogger(__name__) def exception_to_validation_msg(e): - ''' - Extracts a validation message to display to the user. - ''' + """Extracts a validation message to display to the user.""" try: error = json.loads(str(e)) # NOTE(jianingy): if no message exists, we just return 'None' diff --git a/openstack_dashboard/dashboards/project/stacks/mappings.py b/openstack_dashboard/dashboards/project/stacks/mappings.py index 03532912..c6e5acf9 100644 --- a/openstack_dashboard/dashboards/project/stacks/mappings.py +++ b/openstack_dashboard/dashboards/project/stacks/mappings.py @@ -140,9 +140,7 @@ def get_resource_status(status): def get_resource_image(status, type): - ''' - Sets the image url and in_progress action sw based on status. - ''' + """Sets the image url and in_progress action sw based on status.""" resource_type = get_resource_type(type) resource_status = get_resource_status(status) resource_state = resource_type + "_" + resource_status diff --git a/openstack_dashboard/test/helpers.py b/openstack_dashboard/test/helpers.py index 0aefdadd..22603332 100644 --- a/openstack_dashboard/test/helpers.py +++ b/openstack_dashboard/test/helpers.py @@ -108,8 +108,7 @@ class RequestFactoryWithMessages(RequestFactory): @unittest.skipIf(os.environ.get('SKIP_UNITTESTS', False), "The SKIP_UNITTESTS env variable is set.") class TestCase(horizon_helpers.TestCase): - """ - Specialized base test case class for Horizon which gives access to + """Specialized base test case class for Horizon which gives access to numerous additional features: * A full suite of test data through various attached objects and @@ -180,8 +179,7 @@ class TestCase(horizon_helpers.TestCase): utils.get_user = get_user def assertRedirectsNoFollow(self, response, expected_url): - """ - Asserts that the given response issued a 302 redirect without + """Asserts that the given response issued a 302 redirect without processing the view which is redirected to. """ assert (response.status_code / 100 == 3), \ @@ -191,8 +189,7 @@ class TestCase(horizon_helpers.TestCase): self.assertEqual(response.status_code, 302) def assertNoFormErrors(self, response, context_name="form"): - """ - Asserts that the response either does not contain a form in its + """Asserts that the response either does not contain a form in its context, or that if it does, that form has no errors. """ context = getattr(response, "context", {}) @@ -204,8 +201,7 @@ class TestCase(horizon_helpers.TestCase): def assertFormErrors(self, response, count=0, message=None, context_name="form"): - """ - Asserts that the response does contain a form in its + """Asserts that the response does contain a form in its context, and that form has errors, if count were given, it must match the exact numbers of errors """ @@ -226,8 +222,7 @@ class TestCase(horizon_helpers.TestCase): class BaseAdminViewTests(TestCase): - """ - A ``TestCase`` subclass which sets an active user with the "admin" role + """A ``TestCase`` subclass which sets an active user with the "admin" role for testing admin-only views and functionality. """ def setActiveUser(self, *args, **kwargs): @@ -248,8 +243,7 @@ class BaseAdminViewTests(TestCase): class APITestCase(TestCase): - """ - The ``APITestCase`` class is for use with tests which deal with the + """The ``APITestCase`` class is for use with tests which deal with the underlying clients rather than stubbing out the openstack_dashboard.api.* methods. """ @@ -258,8 +252,7 @@ class APITestCase(TestCase): utils.patch_middleware_get_user() def fake_keystoneclient(request, admin=False): - """ - Wrapper function which returns the stub keystoneclient. Only + """Wrapper function which returns the stub keystoneclient. Only necessary because the function takes too many arguments to conveniently be a lambda. """ @@ -414,8 +407,7 @@ class SeleniumTestCase(horizon_helpers.SeleniumTestCase): class SeleniumAdminTestCase(SeleniumTestCase): - """ - A ``TestCase`` subclass which sets an active user with the "admin" role + """A ``TestCase`` subclass which sets an active user with the "admin" role for testing admin-only views and functionality. """ def setActiveUser(self, *args, **kwargs): diff --git a/tox.ini b/tox.ini index 27413e26..23ad8d6a 100644 --- a/tox.ini +++ b/tox.ini @@ -34,8 +34,7 @@ builtins = _ exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,panel_template,dash_template,local_settings.py # E127 continuation line over-indented for visual indent # E128 continuation line under-indented for visual indent -# H4xx docstrings # H701 empty localization string # H702 Formatting operation should be outside of localization method call # H803 git commit title should not end with period (disabled on purpose, see bug #1236621) -ignore = E127,E128,H4,H701,H702,H803 +ignore = E127,E128,H701,H702,H803