diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2010-09-14 14:37:18 +0000 |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2010-09-14 14:37:18 +0000 |
commit | f7f390a2510e91935a14e0b25a6c98d9278c962f (patch) | |
tree | cf3da6631912269fcf97d0c646c2b25cbe84a45f /Lib/test/test_ssl.py | |
parent | 7a84877de1bde4ae8c5ab81fd296a2d9a6f164dc (diff) | |
download | cpython-git-f7f390a2510e91935a14e0b25a6c98d9278c962f.tar.gz |
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.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py index d6f1fce7a7..37261554bc 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): |