#NEWLINE# def handlerAndBytesIO( ) : #NEWLINE# #INDENT# "\n    Construct a 2-tuple of C{(StreamHandler, BytesIO)} for testing interaction\n    with the 'logging' module.\n\n    @return: handler and io object\n    @rtype: tuple of L{StreamHandler} and L{BytesIO}\n    " #NEWLINE# output = BytesIO ( ) #NEWLINE# stream = output #NEWLINE# template = py_logging . BASIC_FORMAT #NEWLINE# if _PY3 : #NEWLINE# #INDENT# stream = TextIOWrapper ( output , encoding = 'utf-8' ) #NEWLINE# #UNINDENT# formatter = py_logging . Formatter ( template ) #NEWLINE# handler = py_logging . StreamHandler ( stream ) #NEWLINE# handler . setFormatter ( formatter ) #NEWLINE# return ( stream , output )