diff --git a/magnumclient/shell.py b/magnumclient/shell.py index 36517528..6bd70819 100644 --- a/magnumclient/shell.py +++ b/magnumclient/shell.py @@ -420,7 +420,8 @@ class OpenStackMagnumShell(object): args = subcommand_parser.parse_args(argv) # Short-circuit and deal with help right away. - if args.func == self.do_help: + # NOTE(jamespage): args.func is not guaranteed with python >= 3.4 + if not hasattr(args, 'func') or args.func == self.do_help: self.do_help(args) return 0 elif args.func == self.do_bash_completion: @@ -551,7 +552,10 @@ class OpenStackMagnumShell(object): help='Display help for .') def do_help(self, args): """Display help about this program or one of its subcommands.""" - if args.command: + # NOTE(jamespage): args.command is not guaranteed with python >= 3.4 + command = getattr(args, 'command', '') + + if command: if args.command in self.subcommands: self.subcommands[args.command].print_help() else: diff --git a/magnumclient/tests/test_shell_args.py b/magnumclient/tests/test_shell_args.py index 5e487737..831b1d0b 100644 --- a/magnumclient/tests/test_shell_args.py +++ b/magnumclient/tests/test_shell_args.py @@ -36,13 +36,13 @@ class TestCommandLineArgument(utils.TestCase): _mandatory_arg_error = [ '.*?^usage: ', - '.*?^error: argument', + '.*?^error: (the following arguments|argument)', ".*?^Try 'magnum help ", ] _few_argument_error = [ '.*?^usage: magnum ', - '.*?^error: too few arguments', + '.*?^error: (the following arguments|too few arguments)', ".*?^Try" ] @@ -189,7 +189,7 @@ class TestCommandLineArgument(utils.TestCase): def test_bay_update_failure_few_args(self, mock_update): _error_msg = [ '.*?^usage: magnum bay-update ', - '.*?^error: too few arguments', + '.*?^error: (the following arguments|too few arguments)', ".*?^Try 'magnum help bay-update' for more information." ] self._test_arg_failure('bay-update', _error_msg) diff --git a/tox.ini b/tox.ini index 77d59061..a4ba0dfe 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] minversion = 1.6 -envlist = py26,py27,py33,pypy,pep8 +envlist = py26,py27,py33,py34,pypy,pep8 skipsdist = True [testenv]