From cbd334d0a8b12bb78ff40a4bdc696a80fa6a393a Mon Sep 17 00:00:00 2001 From: Eric Harney Date: Tue, 12 Jun 2012 21:23:47 -0400 Subject: Unwrap httplib.HTTPConnection after WsgiLimiterProxyTest. Fixes bug 1007307. Change-Id: I0b84d29a86a727b611f60f6be15a6d0d21c17a4b --- Authors | 1 + nova/tests/api/openstack/compute/test_limits.py | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Authors b/Authors index a8f1fc88c..31d6e93dd 100644 --- a/Authors +++ b/Authors @@ -67,6 +67,7 @@ Edouard Thuleau Eldar Nugaev Eoghan Glynn Eric Day +Eric Harney Eric Windisch Evan Callicoat Ewan Mellor 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): -- cgit