summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_builtin.py
diff options
context:
space:
mode:
authorAlex Martelli <aleaxit@gmail.com>2007-08-22 23:21:33 (GMT)
committerAlex Martelli <aleaxit@gmail.com>2007-08-22 23:21:33 (GMT)
commitae211f9abf811a28808667450109ca8e2ea53b49 (patch)
tree5cca7820eb0caa839945420add7fd27d1a63660f /Lib/test/test_builtin.py
parent1dd46a048f4afd9a3bc1e3c9c1603d26f2e33e27 (diff)
downloadcpython-ae211f9abf811a28808667450109ca8e2ea53b49.zip
cpython-ae211f9abf811a28808667450109ca8e2ea53b49.tar.gz
cpython-ae211f9abf811a28808667450109ca8e2ea53b49.tar.bz2
Implement the round functionality for PEP 3141, and add tests for it.
Diffstat (limited to 'Lib/test/test_builtin.py')
-rw-r--r--Lib/test/test_builtin.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py
index d5fc85f..37ea8ba 100644
--- a/Lib/test/test_builtin.py
+++ b/Lib/test/test_builtin.py
@@ -1474,6 +1474,19 @@ class BuiltinTest(unittest.TestCase):
self.assertRaises(TypeError, round)
+ # test generic rounding delegation for reals
+ class TestRound:
+ def __round__(self):
+ return 23
+
+ class TestNoRound:
+ pass
+
+ self.assertEqual(round(TestRound()), 23)
+
+ self.assertRaises(TypeError, round, 1, 2, 3)
+ self.assertRaises(TypeError, round, TestNoRound())
+
def test_setattr(self):
setattr(sys, 'spam', 1)
self.assertEqual(sys.spam, 1)