summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2011-05-07 16:47:48 (GMT)
committerEzio Melotti <ezio.melotti@gmail.com>2011-05-07 16:47:48 (GMT)
commit63e4230c3865f6b15538b61fbecd5d0286b1f0a9 (patch)
treefa313781febbfe2582eae1dbad3bb8076899a389 /Lib
parent362b95102f76d042e7f3865c1ebec5d36c79959a (diff)
downloadcpython-63e4230c3865f6b15538b61fbecd5d0286b1f0a9.zip
cpython-63e4230c3865f6b15538b61fbecd5d0286b1f0a9.tar.gz
cpython-63e4230c3865f6b15538b61fbecd5d0286b1f0a9.tar.bz2
#5421: add tests.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_socket.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
index 67c5413..6a9497b 100644
--- a/Lib/test/test_socket.py
+++ b/Lib/test/test_socket.py
@@ -274,6 +274,36 @@ class GeneralModuleTests(unittest.TestCase):
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