Also accept buffer in Connection.send and .sendall
Not at all sure what i am doing, but according to
http://hg.python.org/cpython/rev/9e718d8f71e8/, buffers are a accepted
type to pass to sendall in Python 2.6.
diff --git a/OpenSSL/test/test_ssl.py b/OpenSSL/test/test_ssl.py
index bfe3114..abc3bbe 100644
--- a/OpenSSL/test/test_ssl.py
+++ b/OpenSSL/test/test_ssl.py
@@ -2136,6 +2136,23 @@
self.assertEquals(client.recv(2), b('xy'))
+ try:
+ buffer
+ except NameError:
+ "cannot test sending buffer without buffer"
+ else:
+ def test_short_buffer(self):
+ """
+ When passed a buffer containing a small number of bytes,
+ :py:obj:`Connection.send` transmits all of them and returns the number of
+ bytes sent.
+ """
+ server, client = self._loopback()
+ count = server.send(buffer(b('xy')))
+ self.assertEquals(count, 2)
+ self.assertEquals(client.recv(2), b('xy'))
+
+
class ConnectionSendallTests(TestCase, _LoopbackMixin):
"""
@@ -2179,6 +2196,21 @@
self.assertEquals(client.recv(1), b('x'))
+ try:
+ buffer
+ except NameError:
+ "cannot test sending buffers without buffers"
+ else:
+ def test_short_buffers(self):
+ """
+ When passed a buffer containing a small number of bytes,
+ :py:obj:`Connection.sendall` transmits all of them.
+ """
+ server, client = self._loopback()
+ server.sendall(buffer(b('x')))
+ self.assertEquals(client.recv(1), b('x'))
+
+
def test_long(self):
"""
:py:obj:`Connection.sendall` transmits all of the bytes in the string passed to