From 3ee1fa3f136dd769710b6b24ca1454ee864bbbd9 Mon Sep 17 00:00:00 2001 From: Mehdi Abaakouk Date: Tue, 23 Jul 2013 17:55:44 +0200 Subject: [PATCH] Always init cfg.CONF before running a test In all tests cfg.CONF is not (re)initialised correctly By chance in ceilometer , the only method that fail when conf is not initialised is cfg.CONF.find_file. And because some tests do special initialisation (ie: the ones that test ceilometer.service.prepare_service stuff), the method cfg.CONF.find_file works when we run all tests. But if you decide to run only one test (like below) that use find_file it fail because cfg.CONF is not initialised. tox -epy27,pep8 api.v2 Not all configurations opts are impacted but only the CLI opts ones that are set only when cfg.CONF() is called. This change initialise cfg.CONF on each test (but the test can continue to reinitialise it if needed) Change-Id: I37842e945a7e2908e17d5ce886e17047a36818f7 --- ceilometer/tests/base.py | 1 + 1 file changed, 1 insertion(+) diff --git a/ceilometer/tests/base.py b/ceilometer/tests/base.py index d4c2f5202..f123c216c 100644 --- a/ceilometer/tests/base.py +++ b/ceilometer/tests/base.py @@ -36,6 +36,7 @@ class TestCase(testtools.TestCase): self.stubs = stubout.StubOutForTesting() self.tempdir = self.useFixture(fixtures.TempDir()) self.useFixture(fixtures.FakeLogger()) + cfg.CONF([], project='ceilometer') # Set a default location for the pipeline config file so the # tests work even if ceilometer is not installed globally on