summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-06-26 15:43:14 +0000
committerGerrit Code Review <review@openstack.org>2013-06-26 15:43:14 +0000
commit42931aaee80a18c855a4b350342f7aa376eb024c (patch)
treefb105b3dc2b99bd0e5844867dcba7d595069f8f6
parentc8422928dabe708202543bf6211996a443c944f0 (diff)
parentd8942ecc632efb1f960d0bb225703e15783dcb7c (diff)
downloadoslo-42931aaee80a18c855a4b350342f7aa376eb024c.zip
oslo-42931aaee80a18c855a4b350342f7aa376eb024c.tar.gz
oslo-42931aaee80a18c855a4b350342f7aa376eb024c.tar.xz
Merge "Refactor KombuStubs fixture."
-rw-r--r--tests/unit/rpc/test_kombu.py32
1 files changed, 22 insertions, 10 deletions
diff --git a/tests/unit/rpc/test_kombu.py b/tests/unit/rpc/test_kombu.py
index 54f8389..372b925 100644
--- a/tests/unit/rpc/test_kombu.py
+++ b/tests/unit/rpc/test_kombu.py
@@ -25,7 +25,9 @@ eventlet.monkey_patch()
import contextlib
import functools
import logging
+import weakref
+import fixtures
import mock
from oslo.config import cfg
import six
@@ -67,17 +69,24 @@ def _raise_exc_stub(stubs, times, obj, method, exc_msg,
return info
-class KombuStubs:
- @staticmethod
+class KombuStubs(fixtures.Fixture):
+ def __init__(self, test):
+ super(KombuStubs, self).__init__()
+
+ # NOTE(rpodolyaka): use a weak ref here to prevent ref cycles
+ self.test = weakref.ref(test)
+
def setUp(self):
+ super(KombuStubs, self).setUp()
+
+ test = self.test()
if kombu:
- self.conf = FLAGS
- self.config(fake_rabbit=True)
- self.config(rpc_response_timeout=5)
- self.rpc = impl_kombu
+ test.config(fake_rabbit=True)
+ test.config(rpc_response_timeout=5)
+ test.rpc = impl_kombu
self.addCleanup(impl_kombu.cleanup)
else:
- self.rpc = None
+ test.rpc = None
class FakeMessage(object):
@@ -96,11 +105,13 @@ class FakeMessage(object):
class RpcKombuTestCase(amqp.BaseRpcAMQPTestCase):
def setUp(self):
- KombuStubs.setUp(self)
- super(RpcKombuTestCase, self).setUp()
if kombu is None:
self.skipTest("Test requires kombu")
+ self.useFixture(KombuStubs(self))
+
+ super(RpcKombuTestCase, self).setUp()
+
def test_reusing_connection(self):
"""Test that reusing a connection returns same one."""
conn_context = self.rpc.create_connection(FLAGS, new=False)
@@ -704,7 +715,8 @@ class RpcKombuTestCase(amqp.BaseRpcAMQPTestCase):
class RpcKombuHATestCase(utils.BaseTestCase):
def setUp(self):
super(RpcKombuHATestCase, self).setUp()
- KombuStubs.setUp(self)
+
+ self.useFixture(KombuStubs(self))
self.addCleanup(FLAGS.reset)
def test_roundrobin_reconnect(self):