[Python-checkins] python/dist/src/Lib/test test_socket.py,1.45,1.46
jhylton@users.sourceforge.net
jhylton@users.sourceforge.net
Wed, 31 Jul 2002 08:57:41 -0700
Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv29024
Modified Files:
test_socket.py
Log Message:
Repair testNtoH for large long arguments.
If the long is large enough, the return value will be a negative int.
In this case, calling the function a second time won't return the
original value passed in.
Index: test_socket.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_socket.py,v
retrieving revision 1.45
retrieving revision 1.46
diff -C2 -d -r1.45 -r1.46
*** test_socket.py 25 Jul 2002 16:01:11 -0000 1.45
--- test_socket.py 31 Jul 2002 15:57:39 -0000 1.46
***************
*** 249,261 ****
def testNtoH(self):
! def twice(f):
! def g(x):
! return f(f(x))
! return g
! for i in (0, 1, 0xffff0000, 2L, (2**32L) - 1):
! self.assertEqual(i, twice(socket.htonl)(i))
! self.assertEqual(i, twice(socket.ntohl)(i))
! self.assertRaises(OverflowError, socket.htonl, 2L**34)
! self.assertRaises(OverflowError, socket.ntohl, 2L**34)
def testGetServByName(self):
--- 249,260 ----
def testNtoH(self):
! for func in socket.htonl, socket.ntohl:
! for i in (0, 1, 0xffff0000, 2L):
! self.assertEqual(i, func(func(i)))
!
! biglong = 2**32L - 1
! swapped = func(biglong)
! self.assert_(swapped == biglong or swapped == -1)
! self.assertRaises(OverflowError, func, 2L**34)
def testGetServByName(self):