@contextmanager
def capture_stderr():
    s = StringIO()
    saved, sys.stderr = sys.stderr, s
    try:
        yield s.getvalue
    finally:
        sys.stderr = saved

# Addresses must be different, to check that environment is not used
# during YAML tests.
Context manager to capture stderr.
dataset/ETHPy150Open ClusterHQ/flocker/benchmark/test/test_script.py/capture_stderr