diff --git a/neutron/tests/unit/test_wsgi.py b/neutron/tests/unit/test_wsgi.py index a6b3f3be74..d122913988 100644 --- a/neutron/tests/unit/test_wsgi.py +++ b/neutron/tests/unit/test_wsgi.py @@ -35,6 +35,11 @@ TEST_VAR_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'var')) +def open_no_proxy(*args, **kwargs): + opener = urllib2.build_opener(urllib2.ProxyHandler({})) + return opener.open(*args, **kwargs) + + class TestWSGIServer(base.BaseTestCase): """WSGI server tests.""" @@ -120,7 +125,8 @@ class TestWSGIServer(base.BaseTestCase): server = wsgi.Server("test_app") server.start(hello_world, 0, host="127.0.0.1") - response = urllib2.urlopen('http://127.0.0.1:%d/' % server.port) + response = open_no_proxy('http://127.0.0.1:%d/' % server.port) + self.assertEqual(greetings, response.read()) server.stop() @@ -1088,7 +1094,8 @@ class TestWSGIServerWithSSL(base.BaseTestCase): server = wsgi.Server("test_app") server.start(hello_world, 0, host="127.0.0.1") - response = urllib2.urlopen('https://127.0.0.1:%d/' % server.port) + response = open_no_proxy('https://127.0.0.1:%d/' % server.port) + self.assertEqual(greetings, response.read()) server.stop() @@ -1107,7 +1114,8 @@ class TestWSGIServerWithSSL(base.BaseTestCase): server = wsgi.Server("test_app") server.start(hello_world, 0, host="127.0.0.1") - response = urllib2.urlopen('https://127.0.0.1:%d/' % server.port) + response = open_no_proxy('https://127.0.0.1:%d/' % server.port) + self.assertEqual(greetings, response.read()) server.stop() @@ -1128,7 +1136,8 @@ class TestWSGIServerWithSSL(base.BaseTestCase): server = wsgi.Server("test_app") server.start(hello_world, 0, host="::1") - response = urllib2.urlopen('https://[::1]:%d/' % server.port) + response = open_no_proxy('https://[::1]:%d/' % server.port) + self.assertEqual(greetings, response.read()) server.stop()