Capture the stdout and stderr based on environment
Capture the stdout and stderr based on the environment variable OS_STDOUT_CAPTURE and OS_STDERR_CAPTURE. This is helpful for using pdb and ipdb for debug. This patch does not change the behavior of testr, because the variables are set to 1 in `.testr.conf` file. Change-Id: I66d01875a6253524bafddf1b4e20f9126466034e
This commit is contained in:
parent
0f75fdc64c
commit
25cd3d3e67
@ -36,8 +36,10 @@ class TestBase(testtools.TestCase):
|
||||
|
||||
self.useFixture(fixtures.FakeLogger('zaqar'))
|
||||
|
||||
# NOTE(kgriffs): Don't monkey-patch stdout since it breaks
|
||||
# debugging with pdb.
|
||||
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))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user