Fix --debug handling in the shell
This sets the debug level globally on root logger so that every debug calls are logged. Change-Id: Ia8d61f213b2bc6c4bcb1038e7ff6ac0104581b4b Closes-Bug: #1259210
This commit is contained in:
@@ -26,6 +26,7 @@ from __future__ import print_function
|
|||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import getpass
|
import getpass
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
import six
|
import six
|
||||||
import sys
|
import sys
|
||||||
@@ -379,6 +380,9 @@ class OpenStackIdentityShell(object):
|
|||||||
self.do_bash_completion(args)
|
self.do_bash_completion(args)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
if args.debug:
|
||||||
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
|
||||||
# TODO(heckj): supporting backwards compatibility with environment
|
# TODO(heckj): supporting backwards compatibility with environment
|
||||||
# variables. To be removed after DEVSTACK is updated, ideally in
|
# variables. To be removed after DEVSTACK is updated, ideally in
|
||||||
# the Grizzly release cycle.
|
# the Grizzly release cycle.
|
||||||
|
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import json
|
import json
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import uuid
|
import uuid
|
||||||
@@ -117,6 +118,15 @@ class ShellTest(utils.TestCase):
|
|||||||
exceptions.CommandError, 'Expecting'):
|
exceptions.CommandError, 'Expecting'):
|
||||||
self.shell('user-list')
|
self.shell('user-list')
|
||||||
|
|
||||||
|
def test_debug(self):
|
||||||
|
logging_mock = mock.MagicMock()
|
||||||
|
with mock.patch('logging.basicConfig', logging_mock):
|
||||||
|
self.assertRaises(exceptions.CommandError,
|
||||||
|
self.shell, '--debug user-list')
|
||||||
|
self.assertTrue(logging_mock.called)
|
||||||
|
self.assertEqual([(), {'level': logging.DEBUG}],
|
||||||
|
list(logging_mock.call_args))
|
||||||
|
|
||||||
def test_auth_password_authurl_no_username(self):
|
def test_auth_password_authurl_no_username(self):
|
||||||
with testtools.ExpectedException(
|
with testtools.ExpectedException(
|
||||||
exceptions.CommandError,
|
exceptions.CommandError,
|
||||||
|
Reference in New Issue
Block a user