[pypy-svn] r61276 - pypy/trunk/lib-python/modified-2.5.2/test

fijal at codespeak.net fijal at codespeak.net
Fri Jan 23 18:00:21 CET 2009


Author: fijal
Date: Fri Jan 23 18:00:21 2009
New Revision: 61276

Added:
   pypy/trunk/lib-python/modified-2.5.2/test/test_float.py
      - copied, changed from r61272, pypy/trunk/lib-python/2.5.2/test/test_float.py
Log:
Try to provide something that does not use __getformat__ if not necessary


Copied: pypy/trunk/lib-python/modified-2.5.2/test/test_float.py (from r61272, pypy/trunk/lib-python/2.5.2/test/test_float.py)
==============================================================================
--- pypy/trunk/lib-python/2.5.2/test/test_float.py	(original)
+++ pypy/trunk/lib-python/modified-2.5.2/test/test_float.py	Fri Jan 23 18:00:21 2009
@@ -83,41 +83,46 @@
 # is accident (today).
 
 class IEEEFormatTestCase(unittest.TestCase):
-    if float.__getformat__("double").startswith("IEEE"):
-        def test_double_specials_do_unpack(self):
-            for fmt, data in [('>d', BE_DOUBLE_INF),
-                              ('>d', BE_DOUBLE_NAN),
-                              ('<d', LE_DOUBLE_INF),
-                              ('<d', LE_DOUBLE_NAN)]:
-                struct.unpack(fmt, data)
-
-    if float.__getformat__("float").startswith("IEEE"):
-        def test_float_specials_do_unpack(self):
-            for fmt, data in [('>f', BE_FLOAT_INF),
-                              ('>f', BE_FLOAT_NAN),
-                              ('<f', LE_FLOAT_INF),
-                              ('<f', LE_FLOAT_NAN)]:
-                struct.unpack(fmt, data)
-
-    if float.__getformat__("double").startswith("IEEE"):
-        def test_negative_zero(self):
-            import math
-            def pos_pos():
-                return 0.0, math.atan2(0.0, -1)
-            def pos_neg():
-                return 0.0, math.atan2(-0.0, -1)
-            def neg_pos():
-                return -0.0, math.atan2(0.0, -1)
-            def neg_neg():
-                return -0.0, math.atan2(-0.0, -1)
-            self.assertEquals(pos_pos(), neg_pos())
-            self.assertEquals(pos_neg(), neg_neg())
+    def test_double_specials_do_unpack(self):
+        for fmt, data in [('>d', BE_DOUBLE_INF),
+                          ('>d', BE_DOUBLE_NAN),
+                          ('<d', LE_DOUBLE_INF),
+                          ('<d', LE_DOUBLE_NAN)]:
+            struct.unpack(fmt, data)
+
+    def test_float_specials_do_unpack(self):
+        for fmt, data in [('>f', BE_FLOAT_INF),
+                          ('>f', BE_FLOAT_NAN),
+                          ('<f', LE_FLOAT_INF),
+                          ('<f', LE_FLOAT_NAN)]:
+            struct.unpack(fmt, data)
+
+    def test_negative_zero(self):
+        import math
+        def pos_pos():
+            return 0.0, math.atan2(0.0, -1)
+        def pos_neg():
+            return 0.0, math.atan2(-0.0, -1)
+        def neg_pos():
+            return -0.0, math.atan2(0.0, -1)
+        def neg_neg():
+            return -0.0, math.atan2(-0.0, -1)
+        self.assertEquals(pos_pos(), neg_pos())
+        self.assertEquals(pos_neg(), neg_neg())
 
 def test_main():
-    test_support.run_unittest(
-        FormatFunctionsTestCase,
-        UnknownFormatTestCase,
-        IEEEFormatTestCase)
+    if hasattr(float, '__getformat__') and float.__getformat__('double').startswith('IEEE'):
+        lst = [IEEEFormatTestCase]
+    else:
+        lst = []
+
+    if test_support.check_impl_detail():
+        lst.extend([
+            FormatFunctionsTestCase,
+            UnknownFormatTestCase,
+            ])
+    
+    test_support.run_unittest(*lst)
 
 if __name__ == '__main__':
     test_main()



More information about the Pypy-commit mailing list