[Python-checkins] r79040 - in python/branches/py3k: Lib/test/test_socket.py

antoine.pitrou python-checkins at python.org
Wed Mar 17 23:50:28 CET 2010


Author: antoine.pitrou
Date: Wed Mar 17 23:50:28 2010
New Revision: 79040

Log:
NOTE: just porting tests here.


Merged revisions 79039 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r79039 | antoine.pitrou | 2010-03-17 23:45:39 +0100 (mer., 17 mars 2010) | 5 lines
  
  Issue #8104: socket.recv_into() and socket.recvfrom_into() now support
  writing into objects supporting the new buffer API, for example bytearrays
  or memoryviews.
........


Modified:
   python/branches/py3k/   (props changed)
   python/branches/py3k/Lib/test/test_socket.py

Modified: python/branches/py3k/Lib/test/test_socket.py
==============================================================================
--- python/branches/py3k/Lib/test/test_socket.py	(original)
+++ python/branches/py3k/Lib/test/test_socket.py	Wed Mar 17 23:50:28 2010
@@ -1312,28 +1312,64 @@
     def __init__(self, methodName='runTest'):
         SocketConnectedTest.__init__(self, methodName=methodName)
 
-    def testRecvInto(self):
+    def testRecvIntoArray(self):
         buf = bytearray(1024)
         nbytes = self.cli_conn.recv_into(buf)
         self.assertEqual(nbytes, len(MSG))
         msg = buf[:len(MSG)]
         self.assertEqual(msg, MSG)
 
-    def _testRecvInto(self):
+    def _testRecvIntoArray(self):
         buf = bytes(MSG)
         self.serv_conn.send(buf)
 
-    def testRecvFromInto(self):
+    def testRecvIntoBytearray(self):
+        buf = bytearray(1024)
+        nbytes = self.cli_conn.recv_into(buf)
+        self.assertEqual(nbytes, len(MSG))
+        msg = buf[:len(MSG)]
+        self.assertEqual(msg, MSG)
+
+    _testRecvIntoBytearray = _testRecvIntoArray
+
+    def testRecvIntoMemoryview(self):
+        buf = bytearray(1024)
+        nbytes = self.cli_conn.recv_into(memoryview(buf))
+        self.assertEqual(nbytes, len(MSG))
+        msg = buf[:len(MSG)]
+        self.assertEqual(msg, MSG)
+
+    _testRecvIntoMemoryview = _testRecvIntoArray
+
+    def testRecvFromIntoArray(self):
         buf = bytearray(1024)
         nbytes, addr = self.cli_conn.recvfrom_into(buf)
         self.assertEqual(nbytes, len(MSG))
         msg = buf[:len(MSG)]
         self.assertEqual(msg, MSG)
 
-    def _testRecvFromInto(self):
+    def _testRecvFromIntoArray(self):
         buf = bytes(MSG)
         self.serv_conn.send(buf)
 
+    def testRecvFromIntoBytearray(self):
+        buf = bytearray(1024)
+        nbytes, addr = self.cli_conn.recvfrom_into(buf)
+        self.assertEqual(nbytes, len(MSG))
+        msg = buf[:len(MSG)]
+        self.assertEqual(msg, MSG)
+
+    _testRecvFromIntoBytearray = _testRecvFromIntoArray
+
+    def testRecvFromIntoMemoryview(self):
+        buf = bytearray(1024)
+        nbytes, addr = self.cli_conn.recvfrom_into(memoryview(buf))
+        self.assertEqual(nbytes, len(MSG))
+        msg = buf[:len(MSG)]
+        self.assertEqual(msg, MSG)
+
+    _testRecvFromIntoMemoryview = _testRecvFromIntoArray
+
 
 TIPC_STYPE = 2000
 TIPC_LOWER = 200


More information about the Python-checkins mailing list