[Python-checkins] r76176 - python/trunk/Lib/test/test_builtin.py

mark.dickinson python-checkins at python.org
Mon Nov 9 18:03:34 CET 2009


Author: mark.dickinson
Date: Mon Nov  9 18:03:34 2009
New Revision: 76176

Log:
Issue #7251: Break out round tests for large values into a separate
test function, and skip that test on Linux/alpha systems with a broken
system round function.

This should turn the Debian/alpha buildbot green.



Modified:
   python/trunk/Lib/test/test_builtin.py

Modified: python/trunk/Lib/test/test_builtin.py
==============================================================================
--- python/trunk/Lib/test/test_builtin.py	(original)
+++ python/trunk/Lib/test/test_builtin.py	Mon Nov  9 18:03:34 2009
@@ -1,5 +1,6 @@
 # Python test set -- built-in functions
 
+import platform
 import test.test_support, unittest
 from test.test_support import fcmp, have_unicode, TESTFN, unlink, \
                               run_unittest, run_with_locale
@@ -1227,9 +1228,6 @@
         self.assertEqual(round(-5.5), -6)
         self.assertEqual(round(-6.5), -7)
 
-        # Issue #1869: integral floats should remain unchanged
-        self.assertEqual(round(5e15+1), 5e15+1)
-
         # Check behavior on ints
         self.assertEqual(round(0), 0)
         self.assertEqual(round(8), 8)
@@ -1262,6 +1260,27 @@
         self.assertRaises(TypeError, round, t)
         self.assertRaises(TypeError, round, t, 0)
 
+    # Some versions of glibc for alpha have a bug that affects
+    # float -> integer rounding (floor, ceil, rint, round) for
+    # values in the range [2**52, 2**53).  See:
+    #
+    #   http://sources.redhat.com/bugzilla/show_bug.cgi?id=5350
+    #
+    # We skip this test on Linux/alpha if it would fail.
+    linux_alpha = (platform.system().startswith('Linux') and
+                   platform.machine().startswith('alpha'))
+    system_round_bug = round(5e15+1) != 5e15+1
+    @unittest.skipIf(linux_alpha and system_round_bug,
+                     "test will fail;  failure is probably due to a "
+                     "buggy system round function")
+    def test_round_large(self):
+        # Issue #1869: integral floats should remain unchanged
+        self.assertEqual(round(5e15-1), 5e15-1)
+        self.assertEqual(round(5e15), 5e15)
+        self.assertEqual(round(5e15+1), 5e15+1)
+        self.assertEqual(round(5e15+2), 5e15+2)
+        self.assertEqual(round(5e15+3), 5e15+3)
+
     def test_setattr(self):
         setattr(sys, 'spam', 1)
         self.assertEqual(sys.spam, 1)


More information about the Python-checkins mailing list