(self)
| 1313 | self.assertRaises(OverflowError, socket.getservbyport, 65536) |
| 1314 | |
| 1315 | def testDefaultTimeout(self): |
| 1316 | # Testing default timeout |
| 1317 | # The default timeout should initially be None |
| 1318 | self.assertEqual(socket.getdefaulttimeout(), None) |
| 1319 | with socket.socket() as s: |
| 1320 | self.assertEqual(s.gettimeout(), None) |
| 1321 | |
| 1322 | # Set the default timeout to 10, and see if it propagates |
| 1323 | with socket_setdefaulttimeout(10): |
| 1324 | self.assertEqual(socket.getdefaulttimeout(), 10) |
| 1325 | with socket.socket() as sock: |
| 1326 | self.assertEqual(sock.gettimeout(), 10) |
| 1327 | |
| 1328 | # Reset the default timeout to None, and see if it propagates |
| 1329 | socket.setdefaulttimeout(None) |
| 1330 | self.assertEqual(socket.getdefaulttimeout(), None) |
| 1331 | with socket.socket() as sock: |
| 1332 | self.assertEqual(sock.gettimeout(), None) |
| 1333 | |
| 1334 | # Check that setting it to an invalid value raises ValueError |
| 1335 | self.assertRaises(ValueError, socket.setdefaulttimeout, -1) |
| 1336 | |
| 1337 | # Check that setting it to an invalid type raises TypeError |
| 1338 | self.assertRaises(TypeError, socket.setdefaulttimeout, "spam") |
| 1339 | |
| 1340 | @unittest.skipUnless(hasattr(socket, 'inet_aton'), |
| 1341 | 'test needs socket.inet_aton()') |
nothing calls this directly
no test coverage detected