summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_ssl.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-09-14 14:37:18 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2010-09-14 14:37:18 (GMT)
commitf7f390a2510e91935a14e0b25a6c98d9278c962f (patch)
treecf3da6631912269fcf97d0c646c2b25cbe84a45f /Lib/test/test_ssl.py
parent7a84877de1bde4ae8c5ab81fd296a2d9a6f164dc (diff)
downloadcpython-f7f390a2510e91935a14e0b25a6c98d9278c962f.zip
cpython-f7f390a2510e91935a14e0b25a6c98d9278c962f.tar.gz
cpython-f7f390a2510e91935a14e0b25a6c98d9278c962f.tar.bz2
Issue #9729: Fix the signature of SSLSocket.recvfrom() and
SSLSocket.sendto() to match the corresponding socket methods. Also, fix various SSLSocket methods to raise socket.error rather than an unhelpful TypeError when called on an unconnected socket. Original patch by Andrew Bennetts. NOTE: obviously, these methods are untested and unused in the real world...
Diffstat (limited to 'Lib/test/test_ssl.py')
-rw-r--r--Lib/test/test_ssl.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py
index d6f1fce..3726155 100644
--- a/Lib/test/test_ssl.py
+++ b/Lib/test/test_ssl.py
@@ -179,6 +179,19 @@ class BasicSocketTests(unittest.TestCase):
del ss
self.assertEqual(wr(), None)
+ def test_wrapped_unconnected(self):
+ # The _delegate_methods in socket.py are correctly delegated to by an
+ # unconnected SSLSocket, so they will raise a socket.error rather than
+ # something unexpected like TypeError.
+ s = socket.socket(socket.AF_INET)
+ ss = ssl.wrap_socket(s)
+ self.assertRaises(socket.error, ss.recv, 1)
+ self.assertRaises(socket.error, ss.recv_into, bytearray(b'x'))
+ self.assertRaises(socket.error, ss.recvfrom, 1)
+ self.assertRaises(socket.error, ss.recvfrom_into, bytearray(b'x'), 1)
+ self.assertRaises(socket.error, ss.send, b'x')
+ self.assertRaises(socket.error, ss.sendto, b'x', ('0.0.0.0', 0))
+
class NetworkedTests(unittest.TestCase):