[Python-checkins] python/dist/src/Lib/test test_decimal.py, 1.14, 1.15

rhettinger at users.sourceforge.net rhettinger at users.sourceforge.net
Wed Nov 24 08:28:51 CET 2004


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2088/test
Modified Files:
	test_decimal.py 
Log Message:
SF bug #1071588	coercing decimal to int doesn't work between -1 and 1
Index: test_decimal.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_decimal.py,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- test_decimal.py	4 Sep 2004 20:09:13 -0000	1.14
+++ test_decimal.py	24 Nov 2004 07:28:48 -0000	1.15
@@ -967,13 +967,13 @@
 self.assertEqual(d, e)
 
 def test_int(self):
- data = '1.0 1.1 1.9 2.0 0.0 -1.0 -1.1 -1.9 -2.0'.split()
- for s in data:
+ for x in range(-250, 250):
+ s = '%0.2f' % (x / 100.0)
 # should work the same as for floats
 self.assertEqual(int(Decimal(s)), int(float(s)))
- # should work the same as ROUND_DOWN
+ # should work the same as to_integral in the ROUND_DOWN mode
 d = Decimal(s)
- r = Context(prec=1, rounding=ROUND_DOWN).create_decimal(s)
+ r = d.to_integral(ROUND_DOWN)
 self.assertEqual(Decimal(int(d)), r)
 
 class ContextAPItests(unittest.TestCase):


More information about the Python-checkins mailing list

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