Merge "print usage when no argument is specified for python3"
This commit is contained in:
@@ -759,7 +759,8 @@ class HelpFormatter(argparse.HelpFormatter):
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
try:
|
try:
|
||||||
OpenStackImagesShell().main(map(encodeutils.safe_decode, sys.argv[1:]))
|
argv = [encodeutils.safe_decode(a) for a in sys.argv[1:]]
|
||||||
|
OpenStackImagesShell().main(argv)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
utils.exit('... terminating glance client', exit_code=130)
|
utils.exit('... terminating glance client', exit_code=130)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@@ -523,6 +523,20 @@ class ShellTest(testutils.TestCase):
|
|||||||
glance_shell = openstack_shell.OpenStackImagesShell()
|
glance_shell = openstack_shell.OpenStackImagesShell()
|
||||||
self.assertRaises(exc.CommandError, glance_shell.main, args.split())
|
self.assertRaises(exc.CommandError, glance_shell.main, args.split())
|
||||||
|
|
||||||
|
@mock.patch('sys.argv', ['glance'])
|
||||||
|
@mock.patch('sys.stdout', six.StringIO())
|
||||||
|
@mock.patch('sys.stderr', six.StringIO())
|
||||||
|
def test_main_noargs(self):
|
||||||
|
# Ensure that main works with no command-line arguments
|
||||||
|
try:
|
||||||
|
openstack_shell.main()
|
||||||
|
except SystemExit:
|
||||||
|
self.fail('Unexpected SystemExit')
|
||||||
|
|
||||||
|
# We expect the normal usage as a result
|
||||||
|
self.assertIn('Command-line interface to the OpenStack Images API',
|
||||||
|
sys.stdout.getvalue())
|
||||||
|
|
||||||
|
|
||||||
class ShellTestWithKeystoneV3Auth(ShellTest):
|
class ShellTestWithKeystoneV3Auth(ShellTest):
|
||||||
# auth environment to use
|
# auth environment to use
|
||||||
|
Reference in New Issue
Block a user