[Python-checkins] cpython (3.1): #5421: add tests.

ezio.melotti python-checkins at python.org
Sat May 7 18:51:58 CEST 2011


http://hg.python.org/cpython/rev/9222c9d747c1
changeset:   69916:9222c9d747c1
branch:      3.1
parent:      69910:61164d09337e
user:        Ezio Melotti <ezio.melotti at gmail.com>
date:        Sat May 07 19:47:48 2011 +0300
summary:
  #5421: add tests.

files:
  Lib/test/test_socket.py |  30 +++++++++++++++++++++++++++++
  1 files changed, 30 insertions(+), 0 deletions(-)


diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
--- a/Lib/test/test_socket.py
+++ b/Lib/test/test_socket.py
@@ -274,6 +274,36 @@
         self.assertRaises(socket.error, raise_gaierror,
                               "Error raising socket exception.")
 
+    def testSendtoErrors(self):
+        # Testing that sendto doens't masks failures. See #10169.
+        s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
+        self.addCleanup(s.close)
+        s.bind(('', 0))
+        sockname = s.getsockname()
+        # 2 args
+        with self.assertRaises(TypeError):
+            s.sendto('\u2620', sockname)
+        with self.assertRaises(TypeError):
+            s.sendto(5j, sockname)
+        with self.assertRaises(TypeError):
+            s.sendto(b'foo', None)
+        # 3 args
+        with self.assertRaises(TypeError):
+            s.sendto('\u2620', 0, sockname)
+        with self.assertRaises(TypeError):
+            s.sendto(5j, 0, sockname)
+        with self.assertRaises(TypeError):
+            s.sendto(b'foo', 0, None)
+        with self.assertRaises(TypeError):
+            s.sendto(b'foo', 'bar', sockname)
+        with self.assertRaises(TypeError):
+            s.sendto(b'foo', None, None)
+        # wrong number of args
+        with self.assertRaises(TypeError):
+            s.sendto(b'foo')
+        with self.assertRaises(TypeError):
+            s.sendto(b'foo', 0, sockname, 4)
+
     def testCrucialConstants(self):
         # Testing for mission critical constants
         socket.AF_INET

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list