[Zope3-checkins] CVS: Zope3/src/zope/i18n/tests - test_formats.py:1.13

Garrett Smith garrett at mojave-corp.com
Fri Mar 26 21:31:50 EST 2004


Update of /cvs-repository/Zope3/src/zope/i18n/tests
In directory cvs.zope.org:/tmp/cvs-serv12605/src/zope/i18n/tests

Modified Files:
	test_formats.py 
Log Message:
Added support for rounding formatted numbers. E.g. 1.49 formatted with
the pattern "0.0" should be "1.5" -- not "1.4". 


=== Zope3/src/zope/i18n/tests/test_formats.py 1.12 => 1.13 ===
--- Zope3/src/zope/i18n/tests/test_formats.py:1.12	Fri Mar  5 17:09:28 2004
+++ Zope3/src/zope/i18n/tests/test_formats.py	Fri Mar 26 21:31:49 2004
@@ -773,9 +773,19 @@
         self.assertEqual(self.format.format(23341.02357, '###0.0#'),
                          '23341.02')
         self.assertEqual(self.format.format(23341.02357, '###0.000#'),
-                         '23341.0235')
+                         '23341.0236')
         self.assertEqual(self.format.format(23341.02, '###0.000#'),
                          '23341.020')
+                         
+    def testRounding(self):
+        self.assertEqual(self.format.format(0.5, '#'), '1')
+        self.assertEqual(self.format.format(0.49, '#'), '0')
+        self.assertEqual(self.format.format(0.45, '0.0'), '0.5')
+        self.assertEqual(self.format.format(150, '0E0'), '2E2')
+        self.assertEqual(self.format.format(149, '0E0'), '1E2')
+        self.assertEqual(self.format.format(1.9999, '0.000'), '2.000')
+        self.assertEqual(self.format.format(1.9999, '0.0000'), '1.9999')
+        
 
     def testFormatScientificDecimal(self):
         self.assertEqual(self.format.format(23341.02357, '0.00####E00'),




More information about the Zope3-Checkins mailing list