From 9a78a83d9d3b3f756d71dd5f612dc0c6256e2a31 Mon Sep 17 00:00:00 2001 From: Luong Anh Tuan Date: Thu, 4 May 2017 21:35:40 +0700 Subject: [PATCH] Using fixtures instead of deprecated mockpatch module This module mockpatch of oslotest[1] is deprecated since version 1.13 and may be removed in version 2.0. Use fixtures.Mock* classes instead[2] [1]OpenStack Testing Framework and Utilities [2]https://docs.openstack.org/developer/oslotest/api/oslotest.mockpatch.html#module-oslotest.mockpatch Change-Id: I844bd3ddb5ac6da4364c9034dcccdaa5265c1658 --- heat/tests/common.py | 8 ++++---- heat/tests/test_template.py | 3 +-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/heat/tests/common.py b/heat/tests/common.py index 54bda0c0f6..16d9a41ed6 100644 --- a/heat/tests/common.py +++ b/heat/tests/common.py @@ -18,7 +18,6 @@ import fixtures import mox from oslo_config import cfg from oslo_log import log as logging -from oslotest import mockpatch import testscenarios import testtools @@ -203,14 +202,15 @@ class HeatTestCase(testscenarios.WithScenarios, generic_rsrc.ResourceWithHiddenPropertyAndAttribute) def patchobject(self, obj, attr, **kwargs): - mockfixture = self.useFixture(mockpatch.PatchObject(obj, attr, - **kwargs)) + mockfixture = self.useFixture(fixtures.MockPatchObject(obj, attr, + **kwargs)) return mockfixture.mock # NOTE(pshchelo): this overrides the testtools.TestCase.patch method # that does simple monkey-patching in favor of mock's patching def patch(self, target, **kwargs): - mockfixture = self.useFixture(mockpatch.Patch(target, **kwargs)) + mockfixture = self.useFixture(fixtures.MockPatch(target, + **kwargs)) return mockfixture.mock def stub_auth(self, ctx=None, **kwargs): diff --git a/heat/tests/test_template.py b/heat/tests/test_template.py index 3bb84ce03d..ee7a5d8094 100644 --- a/heat/tests/test_template.py +++ b/heat/tests/test_template.py @@ -16,7 +16,6 @@ import hashlib import json import fixtures -from oslotest import mockpatch import six from stevedore import extension @@ -109,7 +108,7 @@ class TemplatePluginFixture(fixtures.Fixture): template._template_classes = None clear_template_classes() - self.useFixture(mockpatch.PatchObject( + self.useFixture(fixtures.MockPatchObject( template, '_get_template_extension_manager', new=self._get_template_extension_manager))