#NEWLINE# @ contextmanager #NEWLINE# def capture_log( self , level = logging . DEBUG ) : #NEWLINE# #INDENT# th = TestHandler ( ) #NEWLINE# th . setLevel ( self ) #NEWLINE# logger . addHandler ( th ) #NEWLINE# if ( self . _test_handler is None ) : #NEWLINE# #INDENT# ( yield th . buffer ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# l = len ( self . _test_handler . buffer ) #NEWLINE# ( yield th . buffer ) #NEWLINE# self . _test_handler . buffer = self . _test_handler . buffer [ : l ]