diff options
author | Alex Martelli <aleaxit@gmail.com> | 2007-08-22 23:21:33 (GMT) |
---|---|---|
committer | Alex Martelli <aleaxit@gmail.com> | 2007-08-22 23:21:33 (GMT) |
commit | ae211f9abf811a28808667450109ca8e2ea53b49 (patch) | |
tree | 5cca7820eb0caa839945420add7fd27d1a63660f /Lib/test | |
parent | 1dd46a048f4afd9a3bc1e3c9c1603d26f2e33e27 (diff) | |
download | cpython-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')
-rw-r--r-- | Lib/test/test_builtin.py | 13 |
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) |