(self)
| 977 | |
| 978 | @unittest.expectedFailure # TODO: RUSTPYTHON; error message format differs |
| 979 | def testSendtoErrors(self): |
| 980 | # Testing that sendto doesn't mask failures. See #10169. |
| 981 | s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) |
| 982 | self.addCleanup(s.close) |
| 983 | s.bind(('', 0)) |
| 984 | sockname = s.getsockname() |
| 985 | # 2 args |
| 986 | with self.assertRaises(TypeError) as cm: |
| 987 | s.sendto('\u2620', sockname) |
| 988 | self.assertEqual(str(cm.exception), |
| 989 | "a bytes-like object is required, not 'str'") |
| 990 | with self.assertRaises(TypeError) as cm: |
| 991 | s.sendto(5j, sockname) |
| 992 | self.assertEqual(str(cm.exception), |
| 993 | "a bytes-like object is required, not 'complex'") |
| 994 | with self.assertRaises(TypeError) as cm: |
| 995 | s.sendto(b'foo', None) |
| 996 | self.assertIn('not NoneType',str(cm.exception)) |
| 997 | # 3 args |
| 998 | with self.assertRaises(TypeError) as cm: |
| 999 | s.sendto('\u2620', 0, sockname) |
| 1000 | self.assertEqual(str(cm.exception), |
| 1001 | "a bytes-like object is required, not 'str'") |
| 1002 | with self.assertRaises(TypeError) as cm: |
| 1003 | s.sendto(5j, 0, sockname) |
| 1004 | self.assertEqual(str(cm.exception), |
| 1005 | "a bytes-like object is required, not 'complex'") |
| 1006 | with self.assertRaises(TypeError) as cm: |
| 1007 | s.sendto(b'foo', 0, None) |
| 1008 | self.assertIn('not NoneType', str(cm.exception)) |
| 1009 | with self.assertRaises(TypeError) as cm: |
| 1010 | s.sendto(b'foo', 'bar', sockname) |
| 1011 | with self.assertRaises(TypeError) as cm: |
| 1012 | s.sendto(b'foo', None, None) |
| 1013 | # wrong number of args |
| 1014 | with self.assertRaises(TypeError) as cm: |
| 1015 | s.sendto(b'foo') |
| 1016 | self.assertIn('(1 given)', str(cm.exception)) |
| 1017 | with self.assertRaises(TypeError) as cm: |
| 1018 | s.sendto(b'foo', 0, sockname, 4) |
| 1019 | self.assertIn('(4 given)', str(cm.exception)) |
| 1020 | |
| 1021 | def testCrucialConstants(self): |
| 1022 | # Testing for mission critical constants |
nothing calls this directly
no test coverage detected