From a5bbba4833a6acc802e8a733db6aa307ed8acedf Mon Sep 17 00:00:00 2001 From: Christian Berendt Date: Sun, 21 Sep 2014 21:48:46 +0200 Subject: Do not iterate action.choices if it is none Do not iterate action.choices in the method add_arguments in the class OpenStackHelpFormatter if action.choices is not iterable because it is none. Change-Id: Ie7110adb798326e5856fddfb6a7365c663b84998 Closes-Bug: #1372152 --- keystoneclient/shell.py | 2 ++ keystoneclient/tests/test_shell.py | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/keystoneclient/shell.py b/keystoneclient/shell.py index 61b93e9..ad8d127 100644 --- a/keystoneclient/shell.py +++ b/keystoneclient/shell.py @@ -443,6 +443,8 @@ class OpenStackHelpFormatter(argparse.HelpFormatter): def add_arguments(self, actions): for action in filter(lambda x: not x.option_strings, actions): + if not action.choices: + continue for choice in action.choices: length = len(choice) + self.INDENT_BEFORE_ARGUMENTS if(length > self._max_help_position and diff --git a/keystoneclient/tests/test_shell.py b/keystoneclient/tests/test_shell.py index 2f7586b..fe720fe 100644 --- a/keystoneclient/tests/test_shell.py +++ b/keystoneclient/tests/test_shell.py @@ -115,6 +115,12 @@ class ShellTest(utils.TestCase): self.assertThat(help_text, matchers.MatchesRegex(required)) + def test_help_command_with_no_action_choices(self): + required = 'usage: keystone user-update' + help_text = self.shell('help user-update') + self.assertThat(help_text, + matchers.MatchesRegex(required)) + def test_auth_no_credentials(self): with testtools.ExpectedException( exceptions.CommandError, 'Expecting'): -- cgit v1.2.1