Fix undesirable raw Python error
Using the glanceclient without a subcommand while passing an optional argument triggers the raw Python error `ERROR: 'Namespace' object has no attribute 'func'`. This bug can be reproduced by issuing the command `glance --os-image-api-version 2`. Added a default value to `func` as placeholder so that a help message is shown instead of the Python error. Closes-Bug: #1903727 Change-Id: Ie4288262e408192310cbbc240bd1779b265a64fd
This commit is contained in:
@@ -211,6 +211,14 @@ class ShellTest(testutils.TestCase):
|
||||
self.assertEqual(0, actual)
|
||||
self.assertFalse(et_mock.called)
|
||||
|
||||
def test_help_no_subcommand(self):
|
||||
shell = openstack_shell.OpenStackImagesShell()
|
||||
argstr = '--os-image-api-version 2'
|
||||
with mock.patch.object(shell, '_get_keystone_auth_plugin') as et_mock:
|
||||
actual = shell.main(argstr.split())
|
||||
self.assertEqual(0, actual)
|
||||
self.assertFalse(et_mock.called)
|
||||
|
||||
def test_blank_call(self):
|
||||
shell = openstack_shell.OpenStackImagesShell()
|
||||
with mock.patch.object(shell, '_get_keystone_auth_plugin') as et_mock:
|
||||
|
||||
Reference in New Issue
Block a user