Sync Patch and PatchObject fixtures from oslo-incubator
This change allow us to set a replacement function to these fixtures.
Depends on I32a90b4d47174b6adb53b525a4add7002411b29d
Change-Id: I897db568280c026f92f7f6da8c1ea974274fc037
diff --git a/tempest/openstack/common/fixture/mockpatch.py b/tempest/openstack/common/fixture/mockpatch.py
index 858e77c..d7dcc11 100644
--- a/tempest/openstack/common/fixture/mockpatch.py
+++ b/tempest/openstack/common/fixture/mockpatch.py
@@ -22,14 +22,15 @@
class PatchObject(fixtures.Fixture):
"""Deal with code around mock."""
- def __init__(self, obj, attr, **kwargs):
+ def __init__(self, obj, attr, new=mock.DEFAULT, **kwargs):
self.obj = obj
self.attr = attr
self.kwargs = kwargs
+ self.new = new
def setUp(self):
super(PatchObject, self).setUp()
- _p = mock.patch.object(self.obj, self.attr, **self.kwargs)
+ _p = mock.patch.object(self.obj, self.attr, self.new, **self.kwargs)
self.mock = _p.start()
self.addCleanup(_p.stop)