[Python-checkins] cpython (2.7): Fix failing test on big-endian machines (issue #13806).

antoine.pitrou python-checkins at python.org
Sat Feb 4 16:46:58 CET 2012


http://hg.python.org/cpython/rev/bc6e768de2cc
changeset: 74763:bc6e768de2cc
branch: 2.7
parent: 74758:887d0ab5fb97
user: Antoine Pitrou <solipsis at pitrou.net>
date: Sat Feb 04 16:44:21 2012 +0100
summary:
 Fix failing test on big-endian machines (issue #13806).
files:
 Lib/test/test_audioop.py | 31 ++++++++++++++++++++-------
 1 files changed, 23 insertions(+), 8 deletions(-)
diff --git a/Lib/test/test_audioop.py b/Lib/test/test_audioop.py
--- a/Lib/test/test_audioop.py
+++ b/Lib/test/test_audioop.py
@@ -2,18 +2,19 @@
 import unittest
 from test.test_support import run_unittest
 
+endian = 'big' if audioop.getsample('0円1円', 2, 0) == 1 else 'little'
 
 def gendata1():
 return '0円1円2円'
 
 def gendata2():
- if audioop.getsample('0円1円', 2, 0) == 1:
+ if endian == 'big':
 return '0円0円0円1円0円2円'
 else:
 return '0円0円1円0円2円0円'
 
 def gendata4():
- if audioop.getsample('0円0円0円1円', 4, 0) == 1:
+ if endian == 'big':
 return '0円0円0円0円0円0円0円1円0円0円0円2円'
 else:
 return '0円0円0円0円1円0円0円0円2円0円0円0円'
@@ -111,9 +112,16 @@
 # Cursory
 d = audioop.lin2alaw(data[0], 1)
 self.assertEqual(audioop.alaw2lin(d, 1), data[0])
- self.assertEqual(audioop.alaw2lin(d, 2), b'\x08\x00\x08\x01\x10\x02')
- self.assertEqual(audioop.alaw2lin(d, 4),
- b'\x00\x00\x08\x00\x00\x00\x08\x01\x00\x00\x10\x02')
+ if endian == 'big':
+ self.assertEqual(audioop.alaw2lin(d, 2),
+ b'\x00\x08\x01\x08\x02\x10')
+ self.assertEqual(audioop.alaw2lin(d, 4),
+ b'\x00\x08\x00\x00\x01\x08\x00\x00\x02\x10\x00\x00')
+ else:
+ self.assertEqual(audioop.alaw2lin(d, 2),
+ b'\x08\x00\x08\x01\x10\x02')
+ self.assertEqual(audioop.alaw2lin(d, 4),
+ b'\x00\x00\x08\x00\x00\x00\x08\x01\x00\x00\x10\x02')
 
 def test_lin2ulaw(self):
 self.assertEqual(audioop.lin2ulaw(data[0], 1), '\xff\xe7\xdb')
@@ -124,9 +132,16 @@
 # Cursory
 d = audioop.lin2ulaw(data[0], 1)
 self.assertEqual(audioop.ulaw2lin(d, 1), data[0])
- self.assertEqual(audioop.ulaw2lin(d, 2), b'\x00\x00\x04\x01\x0c\x02')
- self.assertEqual(audioop.ulaw2lin(d, 4),
- b'\x00\x00\x00\x00\x00\x00\x04\x01\x00\x00\x0c\x02')
+ if endian == 'big':
+ self.assertEqual(audioop.ulaw2lin(d, 2),
+ b'\x00\x00\x01\x04\x02\x0c')
+ self.assertEqual(audioop.ulaw2lin(d, 4),
+ b'\x00\x00\x00\x00\x01\x04\x00\x00\x02\x0c\x00\x00')
+ else:
+ self.assertEqual(audioop.ulaw2lin(d, 2),
+ b'\x00\x00\x04\x01\x0c\x02')
+ self.assertEqual(audioop.ulaw2lin(d, 4),
+ b'\x00\x00\x00\x00\x00\x00\x04\x01\x00\x00\x0c\x02')
 
 def test_mul(self):
 data2 = []
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /