summaryrefslogtreecommitdiffstats
path: root/tests/utils.py
diff options
context:
space:
mode:
authorMark McLoughlin <markmc@redhat.com>2013-06-10 14:01:19 +0100
committerMark McLoughlin <markmc@redhat.com>2013-06-25 07:23:51 +0100
commit1667648b7e812db026933b0075e14f2ab1f1c70b (patch)
tree92183533e69cfc3725a1d1c5312529ad9e3fc501 /tests/utils.py
parentbc10b7aeada4ea66e85e10b94b5c219e3c8d2e77 (diff)
downloadoslo-1667648b7e812db026933b0075e14f2ab1f1c70b.tar.gz
oslo-1667648b7e812db026933b0075e14f2ab1f1c70b.tar.xz
oslo-1667648b7e812db026933b0075e14f2ab1f1c70b.zip
Allow BaseTestCase use a different conf object
The new messaging work will register options like rpc_backend and, since the existing RPC API registers those options with CONF, we need to run the messaging tests with a different ConfigOpts object. It's actually probably pretty sane for all unit tests to use a per-test ConfigOpts object rather than cfg.CONF anyway. The kombu and zmq tests have an issue with this where they rely on being able to call self.config() before the base class setUp() is called. Fixing this properly is a little tricky, so for now, initialize self.conf early to cfg.CONF just for these tests. Change-Id: I7b2e3db7c21c511f3ab16ac866e0cc80846cbd80
Diffstat (limited to 'tests/utils.py')
-rw-r--r--tests/utils.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/tests/utils.py b/tests/utils.py
index 794a3d2..e93c278 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -27,17 +27,16 @@ import testtools
from openstack.common import exception
from openstack.common.fixture import moxstubout
-CONF = cfg.CONF
-
class BaseTestCase(testtools.TestCase):
- def setUp(self):
+ def setUp(self, conf=cfg.CONF):
super(BaseTestCase, self).setUp()
moxfixture = self.useFixture(moxstubout.MoxStubout())
self.mox = moxfixture.mox
self.stubs = moxfixture.stubs
- self.addCleanup(CONF.reset)
+ self.conf = conf
+ self.addCleanup(self.conf.reset)
self.useFixture(fixtures.FakeLogger('openstack.common'))
self.useFixture(fixtures.Timeout(30, True))
self.stubs.Set(exception, '_FATAL_EXCEPTION_FORMAT_ERRORS', True)
@@ -46,7 +45,7 @@ class BaseTestCase(testtools.TestCase):
def tearDown(self):
super(BaseTestCase, self).tearDown()
- CONF.reset()
+ self.conf.reset()
self.stubs.UnsetAll()
self.stubs.SmartUnsetAll()
@@ -79,4 +78,4 @@ class BaseTestCase(testtools.TestCase):
"""
group = kw.pop('group', None)
for k, v in kw.iteritems():
- CONF.set_override(k, v, group)
+ self.conf.set_override(k, v, group)