summaryrefslogtreecommitdiffstats
path: root/nova
diff options
context:
space:
mode:
authorEric Harney <eharney@gmail.com>2012-06-12 21:23:47 -0400
committerEric Harney <eharney@gmail.com>2012-06-13 22:22:01 -0400
commitcbd334d0a8b12bb78ff40a4bdc696a80fa6a393a (patch)
tree62097e51f2c615b81e7f629de6cbefc7d922f62c /nova
parentcd085d0ce74fc478c04f1f61c0e5c22d7aa6d208 (diff)
Unwrap httplib.HTTPConnection after WsgiLimiterProxyTest.
Fixes bug 1007307. Change-Id: I0b84d29a86a727b611f60f6be15a6d0d21c17a4b
Diffstat (limited to 'nova')
-rw-r--r--nova/tests/api/openstack/compute/test_limits.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/nova/tests/api/openstack/compute/test_limits.py b/nova/tests/api/openstack/compute/test_limits.py
index b9450ae5d..c08dc5cef 100644
--- a/nova/tests/api/openstack/compute/test_limits.py
+++ b/nova/tests/api/openstack/compute/test_limits.py
@@ -730,6 +730,9 @@ def wire_HTTPConnection_to_WSGI(host, app):
This method may be called multiple times to map different hosts to
different apps.
+
+ This method returns the original HTTPConnection object, so that the caller
+ can restore the default HTTPConnection interface (for all hosts).
"""
class HTTPConnectionDecorator(object):
"""Wraps the real HTTPConnection class so that when you instantiate
@@ -744,7 +747,9 @@ def wire_HTTPConnection_to_WSGI(host, app):
else:
return self.wrapped(connection_host, *args, **kwargs)
+ oldHTTPConnection = httplib.HTTPConnection
httplib.HTTPConnection = HTTPConnectionDecorator(httplib.HTTPConnection)
+ return oldHTTPConnection
class WsgiLimiterProxyTest(BaseLimitTestSuite):
@@ -759,7 +764,8 @@ class WsgiLimiterProxyTest(BaseLimitTestSuite):
"""
super(WsgiLimiterProxyTest, self).setUp()
self.app = limits.WsgiLimiter(TEST_LIMITS)
- wire_HTTPConnection_to_WSGI("169.254.0.1:80", self.app)
+ self.oldHTTPConnection = (
+ wire_HTTPConnection_to_WSGI("169.254.0.1:80", self.app))
self.proxy = limits.WsgiLimiterProxy("169.254.0.1:80")
def test_200(self):
@@ -780,6 +786,10 @@ class WsgiLimiterProxyTest(BaseLimitTestSuite):
self.assertEqual((delay, error), expected)
+ def tearDown(self):
+ # restore original HTTPConnection object
+ httplib.HTTPConnection = self.oldHTTPConnection
+
class LimitsViewBuilderTest(test.TestCase):
def setUp(self):