def format_command_result( command_args, # type: List[str] command_output, # type: str ): # type: (...) -> str """ Format command information for logging. """ command_desc = format_command_args(command_args) text = 'Command arguments: {}\n'.format(command_desc) if not command_output: text += 'Command output: None' elif logger.getEffectiveLevel() > logging.DEBUG: text += 'Command output: [use --verbose to show]' else: if not command_output.endswith('\n'): command_output += '\n' text += 'Command output:\n{}{}'.format(command_output, LOG_DIVIDER) return text
def test_format_command_args(args, expected): actual = format_command_args(args) assert actual == expected