diff options
author | Raymond Hettinger <python@rcn.com> | 2016-09-03 08:55:11 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2016-09-03 08:55:11 (GMT) |
commit | f0f1c239e4addd15180d605306a969a627cb19d5 (patch) | |
tree | b9d88594efebecef059d38320110c1942839be58 /Lib | |
parent | 22c108f0194e1e75e359b9861af28c33fe55a795 (diff) | |
download | cpython-f0f1c239e4addd15180d605306a969a627cb19d5.zip cpython-f0f1c239e4addd15180d605306a969a627cb19d5.tar.gz cpython-f0f1c239e4addd15180d605306a969a627cb19d5.tar.bz2 |
Issue 27936: Fix inconsistent round() behavior between float and int
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_builtin.py | 11 | ||||
-rw-r--r-- | Lib/test/test_long.py | 2 |
2 files changed, 12 insertions, 1 deletions
diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py index 8cc1b00..39c80b0 100644 --- a/Lib/test/test_builtin.py +++ b/Lib/test/test_builtin.py @@ -3,6 +3,8 @@ import ast import builtins import collections +import decimal +import fractions import io import locale import os @@ -1244,6 +1246,15 @@ class BuiltinTest(unittest.TestCase): self.assertEqual(round(5e15+2), 5e15+2) self.assertEqual(round(5e15+3), 5e15+3) + def test_bug_27936(self): + # Verify that ndigits=None means the same as passing in no argument + for x in [1234, + 1234.56, + decimal.Decimal('1234.56'), + fractions.Fraction(123456, 100)]: + self.assertEqual(round(x, None), round(x)) + self.assertEqual(type(round(x, None)), type(round(x))) + def test_setattr(self): setattr(sys, 'spam', 1) self.assertEqual(sys.spam, 1) diff --git a/Lib/test/test_long.py b/Lib/test/test_long.py index b2d008b..4b2d81c 100644 --- a/Lib/test/test_long.py +++ b/Lib/test/test_long.py @@ -967,7 +967,7 @@ class LongTest(unittest.TestCase): self.assertIs(type(got), int) # bad second argument - bad_exponents = ('brian', 2.0, 0j, None) + bad_exponents = ('brian', 2.0, 0j) for e in bad_exponents: self.assertRaises(TypeError, round, 3, e) |