[Python-checkins] cpython (3.2): Issue #13895: fix test_ssl hanging under Ubuntu

antoine.pitrou python-checkins at python.org
Sat Jan 28 17:42:40 CET 2012


http://hg.python.org/cpython/rev/10c79f29e417
changeset:   74668:10c79f29e417
branch:      3.2
parent:      74665:5cf181df7bea
user:        Antoine Pitrou <solipsis at pitrou.net>
date:        Sat Jan 28 17:38:34 2012 +0100
summary:
  Issue #13895: fix test_ssl hanging under Ubuntu

files:
  Lib/test/test_ssl.py |  40 ++++++++++++++++----------------
  1 files changed, 20 insertions(+), 20 deletions(-)


diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py
--- a/Lib/test/test_ssl.py
+++ b/Lib/test/test_ssl.py
@@ -1078,28 +1078,28 @@
                                     chatty=chatty,
                                     connectionchatty=False)
         with server:
-            s = client_context.wrap_socket(socket.socket())
-            s.connect((HOST, server.port))
-            for arg in [indata, bytearray(indata), memoryview(indata)]:
+            with client_context.wrap_socket(socket.socket()) as s:
+                s.connect((HOST, server.port))
+                for arg in [indata, bytearray(indata), memoryview(indata)]:
+                    if connectionchatty:
+                        if support.verbose:
+                            sys.stdout.write(
+                                " client:  sending %r...\n" % indata)
+                    s.write(arg)
+                    outdata = s.read()
+                    if connectionchatty:
+                        if support.verbose:
+                            sys.stdout.write(" client:  read %r\n" % outdata)
+                    if outdata != indata.lower():
+                        raise AssertionError(
+                            "bad data <<%r>> (%d) received; expected <<%r>> (%d)\n"
+                            % (outdata[:20], len(outdata),
+                               indata[:20].lower(), len(indata)))
+                s.write(b"over\n")
                 if connectionchatty:
                     if support.verbose:
-                        sys.stdout.write(
-                            " client:  sending %r...\n" % indata)
-                s.write(arg)
-                outdata = s.read()
-                if connectionchatty:
-                    if support.verbose:
-                        sys.stdout.write(" client:  read %r\n" % outdata)
-                if outdata != indata.lower():
-                    raise AssertionError(
-                        "bad data <<%r>> (%d) received; expected <<%r>> (%d)\n"
-                        % (outdata[:20], len(outdata),
-                           indata[:20].lower(), len(indata)))
-            s.write(b"over\n")
-            if connectionchatty:
-                if support.verbose:
-                    sys.stdout.write(" client:  closing connection.\n")
-            s.close()
+                        sys.stdout.write(" client:  closing connection.\n")
+                s.close()
 
     def try_protocol_combo(server_protocol, client_protocol, expect_success,
                            certsreqs=None, server_options=0, client_options=0):

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list