Skip to content
This repository has been archived by the owner on May 17, 2024. It is now read-only.

Commit

Permalink
Update test module from oslo-incubator
Browse files Browse the repository at this point in the history
Update to sha 1ebf819e31dde74f4374c26a791458ccd25b29d9

Note the new config generator needs stevedore.

Change-Id: I315c52778593c10a63cac363cd58f11141cba6fa
  • Loading branch information
Angus Salkeld committed Jan 28, 2014
1 parent 4c69c73 commit 5660ed4
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .testr.conf
Original file line number Diff line number Diff line change
@@ -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

Expand Down
23 changes: 20 additions & 3 deletions solum/openstack/common/test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4

# Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.
#
Expand All @@ -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):
Expand All @@ -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())

Expand All @@ -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)
2 changes: 0 additions & 2 deletions solum/tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
1 change: 1 addition & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5660ed4

Please sign in to comment.