aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYen Chi Hsuan <yan12125@gmail.com>2016-03-03 21:55:17 +0800
committerYen Chi Hsuan <yan12125@gmail.com>2016-03-03 21:55:17 +0800
commit429491f531035f4fe9e958e6bf4108867107efec (patch)
tree5fdeab02dcecc91eb806f51e6fdcd79aa5a42a63
parente9c0cdd3895436170de33324c1762364380c6a5a (diff)
[test/http] Fix failure in Jython
make offlinetest passed on the latest Jython hg version with patched lib-python/2.7/urllib2.py pulled from CPython 2.7.11
-rw-r--r--test/test_http.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/test/test_http.py b/test/test_http.py
index f2e305b6f..fc59b1aed 100644
--- a/test/test_http.py
+++ b/test/test_http.py
@@ -52,7 +52,12 @@ class TestHTTP(unittest.TestCase):
('localhost', 0), HTTPTestRequestHandler)
self.httpd.socket = ssl.wrap_socket(
self.httpd.socket, certfile=certfn, server_side=True)
- self.port = self.httpd.socket.getsockname()[1]
+ if os.name == 'java':
+ # In Jython SSLSocket is not a subclass of socket.socket
+ sock = self.httpd.socket.sock
+ else:
+ sock = self.httpd.socket
+ self.port = sock.getsockname()[1]
self.server_thread = threading.Thread(target=self.httpd.serve_forever)
self.server_thread.daemon = True
self.server_thread.start()