summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_ssl.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2012-12-28 18:03:43 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2012-12-28 18:03:43 (GMT)
commit40f12ab0c5c5adc4a8b4a03a57ffa94c87ecc2cb (patch)
tree8329b0fe6c8544f4f42cb6ccac746e23479796c4 /Lib/test/test_ssl.py
parentc4051aa8eb3c9c753c23ead3db957408b26fc5a2 (diff)
downloadcpython-40f12ab0c5c5adc4a8b4a03a57ffa94c87ecc2cb.zip
cpython-40f12ab0c5c5adc4a8b4a03a57ffa94c87ecc2cb.tar.gz
cpython-40f12ab0c5c5adc4a8b4a03a57ffa94c87ecc2cb.tar.bz2
Backport Python 3.2 fix for issue #12065, and add another test for SSLSocket.connect_ex().
Diffstat (limited to 'Lib/test/test_ssl.py')
-rw-r--r--Lib/test/test_ssl.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py
index 58da942..9f51387 100644
--- a/Lib/test/test_ssl.py
+++ b/Lib/test/test_ssl.py
@@ -280,6 +280,34 @@ class NetworkedTests(unittest.TestCase):
finally:
s.close()
+ def test_timeout_connect_ex(self):
+ # Issue #12065: on a timeout, connect_ex() should return the original
+ # errno (mimicking the behaviour of non-SSL sockets).
+ with test_support.transient_internet("svn.python.org"):
+ s = ssl.wrap_socket(socket.socket(socket.AF_INET),
+ cert_reqs=ssl.CERT_REQUIRED,
+ ca_certs=SVN_PYTHON_ORG_ROOT_CERT,
+ do_handshake_on_connect=False)
+ try:
+ s.settimeout(0.0000001)
+ rc = s.connect_ex(('svn.python.org', 443))
+ if rc == 0:
+ self.skipTest("svn.python.org responded too quickly")
+ self.assertIn(rc, (errno.EAGAIN, errno.EWOULDBLOCK))
+ finally:
+ s.close()
+
+ def test_connect_ex_error(self):
+ with test_support.transient_internet("svn.python.org"):
+ s = ssl.wrap_socket(socket.socket(socket.AF_INET),
+ cert_reqs=ssl.CERT_REQUIRED,
+ ca_certs=SVN_PYTHON_ORG_ROOT_CERT)
+ try:
+ self.assertEqual(errno.ECONNREFUSED,
+ s.connect_ex(("svn.python.org", 444)))
+ finally:
+ s.close()
+
@unittest.skipIf(os.name == "nt", "Can't use a socket as a file under Windows")
def test_makefile_close(self):
# Issue #5238: creating a file-like object with makefile() shouldn't