Permalink
Browse files

Update test module from oslo-incubator

Update to sha 1ebf819e31dde74f4374c26a791458ccd25b29d9

Note the new config generator needs stevedore.

Change-Id: I315c52778593c10a63cac363cd58f11141cba6fa
  • Loading branch information...
1 parent 4c69c73 commit 5660ed47b5ccfa6bac85e99c4338b952d4bc9d5d @asalkeld asalkeld committed Jan 28, 2014
Showing with 23 additions and 5 deletions.
  1. +2 −0 .testr.conf
  2. +20 −3 solum/openstack/common/test.py
  3. +0 −2 solum/tests/base.py
  4. +1 −0 test-requirements.txt
View
@@ -1,6 +1,8 @@
[DEFAULT]
test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \
OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \
+ OS_LOG_CAPTURE=${OS_LOG_CAPTURE:-1} \
+ OS_DEBUG=${OS_DEBUG:-1} \
OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-60} \
${PYTHON:-python} -m subunit.run discover -t ./ ./solum/tests $LISTOPT $IDOPTION
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.
#
@@ -17,12 +15,14 @@
"""Common utilities used in testing"""
+import logging
import os
import fixtures
import testtools
_TRUE_VALUES = ('True', 'true', '1', 'yes')
+_LOG_FORMAT = "%(levelname)8s [%(name)s] %(message)s"
class BaseTestCase(testtools.TestCase):
@@ -31,7 +31,7 @@ def setUp(self):
super(BaseTestCase, self).setUp()
self._set_timeout()
self._fake_output()
- self.useFixture(fixtures.FakeLogger('solum.openstack.common'))
+ self._fake_logs()
self.useFixture(fixtures.NestedTempfile())
self.useFixture(fixtures.TempHomeDir())
@@ -52,3 +52,20 @@ def _fake_output(self):
if os.environ.get('OS_STDERR_CAPTURE') in _TRUE_VALUES:
stderr = self.useFixture(fixtures.StringStream('stderr')).stream
self.useFixture(fixtures.MonkeyPatch('sys.stderr', stderr))
+
+ def _fake_logs(self):
+ if os.environ.get('OS_DEBUG') in _TRUE_VALUES:
+ level = logging.DEBUG
+ else:
+ level = logging.INFO
+ capture_logs = os.environ.get('OS_LOG_CAPTURE') in _TRUE_VALUES
+ if capture_logs:
+ self.useFixture(
+ fixtures.FakeLogger(
+ format=_LOG_FORMAT,
+ level=level,
+ nuke_handlers=capture_logs,
+ )
+ )
+ else:
+ logging.basicConfig(format=_LOG_FORMAT, level=level)
View
@@ -14,7 +14,6 @@
# License for the specific language governing permissions and limitations
# under the License.
-import fixtures
from oslo.config import cfg
from solum.openstack.common import test
@@ -25,5 +24,4 @@ class BaseTestCase(test.BaseTestCase):
def setUp(self):
super(BaseTestCase, self).setUp()
- self.log_fixture = self.useFixture(fixtures.FakeLogger())
self.addCleanup(cfg.CONF.reset)
View
@@ -11,6 +11,7 @@ oslo.sphinx
sphinxcontrib-pecanwsme>=0.6
sphinxcontrib-httpdomain
docutils==0.9.1
+stevedore>=0.12
testrepository>=0.0.17
testscenarios>=0.4
testtools>=0.9.32

0 comments on commit 5660ed4

Please sign in to comment.