diff --git a/ceilometer/tests/base.py b/ceilometer/tests/base.py index 3914788f3..bb7530170 100644 --- a/ceilometer/tests/base.py +++ b/ceilometer/tests/base.py @@ -51,6 +51,12 @@ class BaseTestCase(test.BaseTestCase): 'ceilometer.messaging.get_transport', return_value=self.transport)) + def setUp(self): + super(BaseTestCase, self).setUp() + self.useFixture(mockpatch.Patch( + 'oslo.config.cfg._get_config_dirs', + return_value=[self.path_get('etc/ceilometer')])) + def assertTimestampEqual(self, first, second, msg=None): """Checks that two timestamps are equals. diff --git a/ceilometer/tests/compute/pollsters/base.py b/ceilometer/tests/compute/pollsters/base.py index e7ff4b2d2..a9afc64f9 100644 --- a/ceilometer/tests/compute/pollsters/base.py +++ b/ceilometer/tests/compute/pollsters/base.py @@ -19,6 +19,7 @@ import mock +from ceilometer.openstack.common.fixture import mockpatch import ceilometer.tests.base as base @@ -27,8 +28,6 @@ class TestPollsterBase(base.BaseTestCase): def setUp(self): super(TestPollsterBase, self).setUp() - self.addCleanup(mock.patch.stopall) - self.inspector = mock.Mock() self.instance = mock.MagicMock() self.instance.name = 'instance-00000001' @@ -39,7 +38,7 @@ class TestPollsterBase(base.BaseTestCase): 'ram': 512, 'disk': 20, 'ephemeral': 0} self.instance.status = 'active' - patch_virt = mock.patch('ceilometer.compute.virt.inspector' - '.get_hypervisor_inspector', - mock.Mock(return_value=self.inspector)) - patch_virt.start() + patch_virt = mockpatch.Patch( + 'ceilometer.compute.virt.inspector.get_hypervisor_inspector', + new=mock.Mock(return_value=self.inspector)) + self.useFixture(patch_virt)