Merge "Do not iterate action.choices if it is none"
This commit is contained in:
@@ -443,6 +443,8 @@ class OpenStackHelpFormatter(argparse.HelpFormatter):
|
|||||||
|
|
||||||
def add_arguments(self, actions):
|
def add_arguments(self, actions):
|
||||||
for action in filter(lambda x: not x.option_strings, actions):
|
for action in filter(lambda x: not x.option_strings, actions):
|
||||||
|
if not action.choices:
|
||||||
|
continue
|
||||||
for choice in action.choices:
|
for choice in action.choices:
|
||||||
length = len(choice) + self.INDENT_BEFORE_ARGUMENTS
|
length = len(choice) + self.INDENT_BEFORE_ARGUMENTS
|
||||||
if(length > self._max_help_position and
|
if(length > self._max_help_position and
|
||||||
|
@@ -115,6 +115,12 @@ class ShellTest(utils.TestCase):
|
|||||||
self.assertThat(help_text,
|
self.assertThat(help_text,
|
||||||
matchers.MatchesRegex(required))
|
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):
|
def test_auth_no_credentials(self):
|
||||||
with testtools.ExpectedException(
|
with testtools.ExpectedException(
|
||||||
exceptions.CommandError, 'Expecting'):
|
exceptions.CommandError, 'Expecting'):
|
||||||
|
Reference in New Issue
Block a user