#NEWLINE# def test_colorizing_support( logger ) : #NEWLINE# #INDENT# from logbook.more import ColorizedStderrHandler #NEWLINE# class TestColorizingHandler ( ColorizedStderrHandler ) : #NEWLINE# #INDENT# def should_colorize( self , record ) : #NEWLINE# #INDENT# return True #NEWLINE# #UNINDENT# stream = StringIO ( ) #NEWLINE# #UNINDENT# with TestColorizingHandler ( format_string = '{record.message}' ) as handler : #NEWLINE# #INDENT# logger . error ( 'An error' ) #NEWLINE# logger . warn ( 'A warning' ) #NEWLINE# logger . debug ( 'A debug message' ) #NEWLINE# lines = handler . stream . getvalue ( ) . rstrip ( '\n' ) . splitlines ( ) #NEWLINE# assert ( lines == [ '\x1b[31;01mAn error\x1b[39;49;00m' , '\x1b[33;01mA warning\x1b[39;49;00m' , '\x1b[37mA debug message\x1b[39;49;00m' ] )