[Python-checkins] r83821 - python/branches/py3k-dtoa/Lib/test/test_float.py

mark.dickinson python-checkins at python.org
Sun Aug 8 13:44:52 CEST 2010


Author: mark.dickinson
Date: Sun Aug  8 13:44:52 2010
New Revision: 83821

Log:
Make saving and restoration of old rounding mode neater.

Modified:
   python/branches/py3k-dtoa/Lib/test/test_float.py

Modified: python/branches/py3k-dtoa/Lib/test/test_float.py
==============================================================================
--- python/branches/py3k-dtoa/Lib/test/test_float.py	(original)
+++ python/branches/py3k-dtoa/Lib/test/test_float.py	Sun Aug  8 13:44:52 2010
@@ -389,16 +389,19 @@
 
 @requires_setround
 class RoundingModeTestCase(unittest.TestCase):
+    def setUp(self):
+        self.save_mode = float.__getround__()
+
+    def tearDown(self):
+        float.__setround__(self.save_mode)
+
     def test_roundtrip(self):
         # just check that we can use __setround__ and __getround__
         # to set and get rounding mode
         modes = "tonearest", "upward", "downward", "towardzero"
         for mode in modes:
-            oldmode = float.__getround__()
             float.__setround__(mode)
             self.assertEqual(float.__getround__(), mode)
-            float.__setround__(oldmode)
-            self.assertEqual(float.__getround__(), oldmode)
 
 @requires_setformat
 class FormatFunctionsTestCase(unittest.TestCase):


More information about the Python-checkins mailing list