From 497d222ecd790c79e22a6aada38862b7e58f55c4 Mon Sep 17 00:00:00 2001 From: Chang Bo Guo Date: Mon, 18 Nov 2013 02:27:55 -0800 Subject: [PATCH] Clean up how test env variables are parsed Oslo and cookiecutter and other projects were using variable to parse test environment vaiables. Let us do this in Nova This is copied from 739627bf79619f8 Use cleaner version from cookiecutter OpenStack template Change-Id: I4c2b4072981985e7632fc775ffc98216fbfc0508 --- nova/test.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/nova/test.py b/nova/test.py index 98feeafaec3f..9738b76099e3 100644 --- a/nova/test.py +++ b/nova/test.py @@ -71,6 +71,7 @@ CONF.set_override('use_stderr', False) logging.setup('nova') _DB_CACHE = None +_TRUE_VALUES = ('True', 'true', '1', 'yes') class Database(fixtures.Fixture): @@ -214,12 +215,10 @@ class TestCase(testtools.TestCase): self.useFixture(fixtures.TempHomeDir()) self.useFixture(TranslationFixture()) - if (os.environ.get('OS_STDOUT_CAPTURE') == 'True' or - os.environ.get('OS_STDOUT_CAPTURE') == '1'): + if os.environ.get('OS_STDOUT_CAPTURE') in _TRUE_VALUES: stdout = self.useFixture(fixtures.StringStream('stdout')).stream self.useFixture(fixtures.MonkeyPatch('sys.stdout', stdout)) - if (os.environ.get('OS_STDERR_CAPTURE') == 'True' or - os.environ.get('OS_STDERR_CAPTURE') == '1'): + if os.environ.get('OS_STDERR_CAPTURE') in _TRUE_VALUES: stderr = self.useFixture(fixtures.StringStream('stderr')).stream self.useFixture(fixtures.MonkeyPatch('sys.stderr', stderr))