def print_attachments(stream, test, all_channels=False):
 channels = ('stdout', 'stderr')
 for (name, detail) in test['details'].items():
  name = name.split(':')[0]
  if (detail.content_type.type == 'test'):
   detail.content_type.type = 'text'
  if ((all_channels or (name in channels)) and detail.as_text()):
   title = ('Captured %s:' % name)
   stream.write(('\n%s\n%s\n' % (title, ('~' * len(title)))))
   for line in detail.as_text().split('\n'):
    stream.write(('    %s\n' % line))

def print_attachments ( stream , test , all_channels = False ) : channels = ( 'stdout' , 'stderr' ) for ( name , detail ) in test [ 'details' ] . items ( ) : name = name . split ( ':' ) [ 0 ] if ( detail . content_type . type == 'test' ) : detail . content_type . type = 'text' if ( ( all_channels or ( name in channels ) ) and detail . as_text ( ) ) : title = ( 'Captured %s:' % name ) stream . write ( ( '\n%s\n%s\n' % ( title , ( '~' * len ( title ) ) ) ) ) for line in detail . as_text ( ) . split ( '\n' ) : stream . write ( ( '    %s\n' % line ) )
print out subunit attachments .