From 1667648b7e812db026933b0075e14f2ab1f1c70b Mon Sep 17 00:00:00 2001 From: Mark McLoughlin Date: Mon, 10 Jun 2013 14:01:19 +0100 Subject: 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 --- tests/utils.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'tests/utils.py') 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) -- cgit