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 getpass
|
||||
import logging
|
||||
import os
|
||||
import six
|
||||
import sys
|
||||
@@ -379,6 +380,9 @@ class OpenStackIdentityShell(object):
|
||||
self.do_bash_completion(args)
|
||||
return 0
|
||||
|
||||
if args.debug:
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
|
||||
# TODO(heckj): supporting backwards compatibility with environment
|
||||
# variables. To be removed after DEVSTACK is updated, ideally in
|
||||
# the Grizzly release cycle.
|
||||
|
@@ -14,6 +14,7 @@
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
import uuid
|
||||
@@ -117,6 +118,15 @@ class ShellTest(utils.TestCase):
|
||||
exceptions.CommandError, 'Expecting'):
|
||||
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):
|
||||
with testtools.ExpectedException(
|
||||
exceptions.CommandError,
|
||||
|
Reference in New Issue
Block a user