mirror of
https://github.com/python/cpython.git
synced 2025-09-27 10:50:04 +00:00
Maybe this fixes test_socket on 64-bit Linux.
This commit is contained in:
parent
92cfaf68c7
commit
a2627afe37
1 changed files with 12 additions and 8 deletions
|
@ -248,15 +248,19 @@ class GeneralModuleTests(unittest.TestCase):
|
||||||
except socket.error:
|
except socket.error:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def testNtoH(self):
|
def testNtoHL(self):
|
||||||
for func in socket.htonl, socket.ntohl:
|
# This just checks that htons etc. are their own inverse,
|
||||||
for i in (0, 1, ~0xffff, 2L):
|
# when looking at the lower 16 or 32 bits.
|
||||||
self.assertEqual(i, func(func(i)))
|
sizes = {socket.htonl: 32, socket.ntohl: 32,
|
||||||
|
socket.htons: 16, socket.ntohs: 16}
|
||||||
|
for func, size in sizes.items():
|
||||||
|
mask = (1L<<size) - 1
|
||||||
|
for i in (0, 1, 0xffff, ~0xffff, 2, 0x01234567, 0x76543210):
|
||||||
|
self.assertEqual(i & mask, func(func(i&mask)) & mask)
|
||||||
|
|
||||||
biglong = 2**32L - 1
|
swapped = func(mask)
|
||||||
swapped = func(biglong)
|
self.assertEqual(swapped & mask, mask)
|
||||||
self.assert_(swapped == biglong or swapped == -1)
|
self.assertRaises(OverflowError, func, 1L<<34)
|
||||||
self.assertRaises(OverflowError, func, 2L**34)
|
|
||||||
|
|
||||||
def testGetServByName(self):
|
def testGetServByName(self):
|
||||||
# Testing getservbyname()
|
# Testing getservbyname()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue