[Python-checkins] cpython: Issue #11888: skip some log2 tests on Mac OS X Tiger

victor.stinner python-checkins at python.org
Tue May 10 23:42:44 CEST 2011


http://hg.python.org/cpython/rev/34871c3072c9
changeset: 70018:34871c3072c9
user: Victor Stinner <victor.stinner at haypocalc.com>
date: Tue May 10 23:40:17 2011 +0200
summary:
 Issue #11888: skip some log2 tests on Mac OS X Tiger
System log2() is not accurate for exact power of 2.
files:
 Lib/test/test_math.py | 15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/Lib/test/test_math.py b/Lib/test/test_math.py
--- a/Lib/test/test_math.py
+++ b/Lib/test/test_math.py
@@ -5,6 +5,7 @@
 import unittest
 import math
 import os
+import platform
 import sys
 import struct
 import sysconfig
@@ -652,10 +653,6 @@
 @requires_IEEE_754
 def testLog2(self):
 self.assertRaises(TypeError, math.log2)
- # Check that we get exact equality for log2 of powers of 2.
- actual = [math.log2(math.ldexp(1.0, n)) for n in range(-1074, 1024)]
- expected = [float(n) for n in range(-1074, 1024)]
- self.assertEqual(actual, expected)
 
 # Check some integer values
 self.assertEqual(math.log2(1), 0.0)
@@ -671,6 +668,16 @@
 self.assertRaises(ValueError, math.log2, NINF)
 self.assertTrue(math.isnan(math.log2(NAN)))
 
+ @requires_IEEE_754
+ @unittest.skipIf(sys.platform == 'darwin'
+ and platform.mac_ver()[0].startswith('10.4.'),
+ 'Mac OS X Tiger log2() is not accurate enough')
+ def testLog2Exact(self):
+ # Check that we get exact equality for log2 of powers of 2.
+ actual = [math.log2(math.ldexp(1.0, n)) for n in range(-1074, 1024)]
+ expected = [float(n) for n in range(-1074, 1024)]
+ self.assertEqual(actual, expected)
+
 def testLog10(self):
 self.assertRaises(TypeError, math.log10)
 self.ftest('log10(0.1)', math.log10(0.1), -1)
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

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