Merge "Fix --debug handling in the shell"

This commit is contained in:
Jenkins
2013-12-16 21:45:26 +00:00
committed by Gerrit Code Review
2 changed files with 14 additions and 0 deletions

View File

@@ -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.

View File

@@ -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,