diff options
author | Salvatore Orlando <salvatore.orlando@eu.citrix.com> | 2011-03-24 02:01:46 +0000 |
---|---|---|
committer | Salvatore Orlando <salvatore.orlando@eu.citrix.com> | 2011-03-24 02:01:46 +0000 |
commit | 52bd70d500e7e82acea55c8d23c3fd1d66555cc0 (patch) | |
tree | 89018a7985a12d364d7f537475ed10f314e1fa06 /nova/tests/fake_utils.py | |
parent | b8c943bc5115e310f1263e275b707d142a372fdb (diff) | |
download | nova-52bd70d500e7e82acea55c8d23c3fd1d66555cc0.tar.gz |
Addressing Rick Clark's comments.
Diffstat (limited to 'nova/tests/fake_utils.py')
-rw-r--r-- | nova/tests/fake_utils.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/nova/tests/fake_utils.py b/nova/tests/fake_utils.py index 8982f50be7..823c775cb7 100644 --- a/nova/tests/fake_utils.py +++ b/nova/tests/fake_utils.py @@ -33,7 +33,6 @@ _fake_execute_log = [] def fake_execute_get_log(): - global _fake_execute_log return _fake_execute_log @@ -55,7 +54,7 @@ def fake_execute_default_reply_handler(*ignore_args, **ignore_kwargs): return '', '' -def fake_execute(*cmd, **kwargs): +def fake_execute(*cmd_parts, **kwargs): """This function stubs out execute, optionally executing a preconfigued function to return expected data """ @@ -64,8 +63,7 @@ def fake_execute(*cmd, **kwargs): process_input = kwargs.get('process_input', None) addl_env = kwargs.get('addl_env', None) check_exit_code = kwargs.get('check_exit_code', 0) - cmd_map = map(str, cmd) - cmd_str = ' '.join(cmd_map) + cmd_str = ' '.join(str(part) for part in cmd_parts) LOG.debug(_("Faking execution of cmd (subprocess): %s"), cmd_str) _fake_execute_log.append(cmd_str) @@ -78,13 +76,13 @@ def fake_execute(*cmd, **kwargs): LOG.debug(_('Faked command matched %s') % fake_replier[0]) break - if isinstance(reply_handler, types.StringTypes): + if isinstance(reply_handler, basestring): # If the reply handler is a string, return it as stdout reply = reply_handler, '' else: try: # Alternative is a function, so call it - reply = reply_handler(cmd, + reply = reply_handler(cmd_parts, process_input=process_input, addl_env=addl_env, check_exit_code=check_exit_code) @@ -92,8 +90,10 @@ def fake_execute(*cmd, **kwargs): LOG.debug(_('Faked command raised an exception %s' % str(e))) raise - LOG.debug(_("Reply to faked command is stdout='%(0)s' stderr='%(1)s'") % - {'0': reply[0], '1': reply[1]}) + stdout = reply[0] + stderr = reply[1] + LOG.debug(_("Reply to faked command is stdout='%(stdout)s' " + "stderr='%(stderr)s'") % locals()) # Replicate the sleep call in the real function greenthread.sleep(0) |