mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
19 lines
387 B
Python
19 lines
387 B
Python
|
import sys
|
||
|
|
||
|
import six
|
||
|
|
||
|
|
||
|
class FakeStdStreams(object):
|
||
|
"""
|
||
|
Redirects stdout and stderr to StringIO.
|
||
|
"""
|
||
|
def __enter__(self):
|
||
|
self._orig_stdout = sys.stdout
|
||
|
self._orig_stderr = sys.stderr
|
||
|
sys.stdout = six.StringIO()
|
||
|
sys.stderr = six.StringIO()
|
||
|
|
||
|
def __exit__(self, exc_type, exc_val, exc_tb):
|
||
|
sys.stdout = self._orig_stdout
|
||
|
sys.stderr = self._orig_stderr
|