Merge "Capture the stdout and stderr based on environment"

This commit is contained in:
Jenkins 2014-11-14 03:00:52 +00:00 committed by Gerrit Code Review
commit 79b125b9db

View File

@ -38,10 +38,12 @@ class TestBase(testtools.TestCase):
self.useFixture(fixtures.FakeLogger('zaqar'))
# NOTE(kgriffs): Don't monkey-patch stdout since it breaks
# debugging with pdb.
stderr = self.useFixture(fixtures.StringStream('stderr')).stream
self.useFixture(fixtures.MonkeyPatch('sys.stderr', stderr))
if os.environ.get('OS_STDOUT_CAPTURE') is not None:
stdout = self.useFixture(fixtures.StringStream('stdout')).stream
self.useFixture(fixtures.MonkeyPatch('sys.stdout', stdout))
if os.environ.get('OS_STDERR_CAPTURE') is not None:
stderr = self.useFixture(fixtures.StringStream('stderr')).stream
self.useFixture(fixtures.MonkeyPatch('sys.stderr', stderr))
if self.config_file:
self.conf = self.load_conf(self.config_file)