<s> from __future__ import absolute_import , unicode_literals <EOL> import contextlib <EOL> import io <EOL> import sys <EOL> @ contextlib . contextmanager <EOL> def redirect_std ( ) : <EOL> oldout , olderr = sys . stdout , sys . stderr <EOL> try : <EOL> std = { <EOL> '<STR_LIT>' : io . StringIO ( ) , <EOL> '<STR_LIT>' : io . StringIO ( ) , <EOL> } <EOL> sys . stdout , sys . stderr = std [ '<STR_LIT>' ] , std [ '<STR_LIT>' ] <EOL> yield std <EOL> finally : <EOL> sys . stdout , sys . stderr = oldout , olderr </s>
