From 96adb2a6c255f96e9d82c86ec37072c30aec021c Mon Sep 17 00:00:00 2001 From: Maru Newby Date: Tue, 3 Sep 2013 16:35:52 +0000 Subject: [PATCH] Default to not capturing log output in tests Viewing log output while tests are still running can be useful for debugging, but log output was previously always captured. This change ensures that log capture is off by default, but can still be enabled by setting OS_LOG_CAPTURE=1 in the shell environment. testr invocation is unchanged and will continue to capture logs by default. Change-Id: I9d0fb648541280cacfebb47f67f608378ae66ef3 --- .testr.conf | 2 +- neutron/tests/base.py | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.testr.conf b/.testr.conf index 71914404665..01d160ec50c 100644 --- a/.testr.conf +++ b/.testr.conf @@ -1,4 +1,4 @@ [DEFAULT] -test_command=OS_STDOUT_CAPTURE=1 OS_STDERR_CAPTURE=1 ${PYTHON:-python} -m subunit.run discover -t ./ neutron/tests/unit $LISTOPT $IDOPTION +test_command=OS_STDOUT_CAPTURE=1 OS_STDERR_CAPTURE=1 OS_LOG_CAPTURE=1 ${PYTHON:-python} -m subunit.run discover -t ./ neutron/tests/unit $LISTOPT $IDOPTION test_id_option=--load-list $IDFILE test_list_option=--list diff --git a/neutron/tests/base.py b/neutron/tests/base.py index 3bb5a2e093b..82fd051fa6a 100644 --- a/neutron/tests/base.py +++ b/neutron/tests/base.py @@ -42,7 +42,15 @@ class BaseTestCase(testtools.TestCase): _level = logging.DEBUG else: _level = logging.INFO - self.useFixture(fixtures.FakeLogger(format=LOG_FORMAT, level=_level)) + capture_logs = os.environ.get('OS_LOG_CAPTURE') in TRUE_STRING + if not capture_logs: + logging.basicConfig(format=LOG_FORMAT, level=_level) + self.log_fixture = self.useFixture( + fixtures.FakeLogger( + format=LOG_FORMAT, + level=_level, + nuke_handlers=capture_logs, + )) test_timeout = int(os.environ.get('OS_TEST_TIMEOUT', 0)) if test_timeout == -1: