[Python-checkins] python/dist/src/Lib/test test_array.py,1.22,1.23
doerwalter@users.sourceforge.net
doerwalter@users.sourceforge.net
2003年5月22日 06:15:34 -0700
Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1:/tmp/cvs-serv13636/Lib/test
Modified Files:
test_array.py
Log Message:
test_byteswap() fails on alphas, because treating the byte swapped bit
patterns as floats/doubles results in floating point exceptions.
Fix this by implementing a separate test_byteswap() for the floating
point tests. This new test compares the tostring() values of both arrays
instead of the arrays themselves.
Discovered by Neal Norwitz.
Index: test_array.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_array.py,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** test_array.py 18 May 2003 03:15:08 -0000 1.22
--- test_array.py 22 May 2003 13:15:31 -0000 1.23
***************
*** 848,851 ****
--- 848,868 ----
typecode = 'f'
minitemsize = 4
+
+ def test_byteswap(self):
+ a = array.array(self.typecode, self.example)
+ self.assertRaises(TypeError, a.byteswap, 42)
+ if a.itemsize in (1, 2, 4, 8):
+ b = array.array(self.typecode, self.example)
+ b.byteswap()
+ if a.itemsize==1:
+ self.assertEqual(a, b)
+ else:
+ # On alphas treating the byte swapped bit patters as
+ # floats/doubles results in floating point exceptions
+ # => compare the 8bit string values instead
+ self.assertNotEqual(a.tostring(), b.tostring())
+ b.byteswap()
+ self.assertEqual(a, b)
+
tests.append(FloatTest)