#NEWLINE# @ contextmanager #NEWLINE# def catch_stdout( ) : #NEWLINE# #INDENT# " Context manager that catch stdout and return StringIO instance.\n    It's good to test any type of terminal outputs.\n    " #NEWLINE# old_out = sys . stdout #NEWLINE# out = six . StringIO ( ) #NEWLINE# sys . stdout = old_out #NEWLINE# ( yield out ) #NEWLINE# sys . stdout = old_out