new method 'HeatTestCase.patchobject'

This patch introduce this method helper to use mockpatch from Oslo
and so benefit of mock and fixtures

Change-Id: Iac3c0d17a77f33b1ebf2ddc69db8237998947925
This commit is contained in:
Swann Croiset 2014-01-16 17:32:11 +01:00
parent 8fec58f158
commit 54016d8af6
1 changed files with 6 additions and 0 deletions

View File

@ -24,6 +24,8 @@ import testtools
from oslo.config import cfg
from heat.openstack.common.fixture import mockpatch
from heat.engine import environment
from heat.engine import resources
from heat.engine import scheduler
@ -80,3 +82,7 @@ class HeatTestCase(testscenarios.WithScenarios, testtools.TestCase):
self.m.StubOutWithMock(scheduler, 'wallclock')
scheduler.wallclock = fake_wallclock
def patchobject(self, obj, attr):
mockfixture = self.useFixture(mockpatch.PatchObject(obj, attr))
return mockfixture.mock