diff options
author | Raymond Hettinger <python@rcn.com> | 2004-11-24 07:28:48 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2004-11-24 07:28:48 (GMT) |
commit | 605ed0248375bbf87bbd1d80afc7c6918fd3ce2b (patch) | |
tree | 92c01fd62467bb05704330da04f0f4c9d468cf66 /Lib/test/test_decimal.py | |
parent | 8f2c4eed93fd0aab1fbcce1e8e57ffea358c4901 (diff) | |
download | cpython-605ed0248375bbf87bbd1d80afc7c6918fd3ce2b.zip cpython-605ed0248375bbf87bbd1d80afc7c6918fd3ce2b.tar.gz cpython-605ed0248375bbf87bbd1d80afc7c6918fd3ce2b.tar.bz2 |
SF bug #1071588 coercing decimal to int doesn't work between -1 and 1
Diffstat (limited to 'Lib/test/test_decimal.py')
-rw-r--r-- | Lib/test/test_decimal.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py index a4e4041..06e8b9d 100644 --- a/Lib/test/test_decimal.py +++ b/Lib/test/test_decimal.py @@ -967,13 +967,13 @@ class DecimalPythonAPItests(unittest.TestCase): 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): |