diff options
author | Alex Martelli <aleaxit@gmail.com> | 2007-08-22 22:39:42 (GMT) |
---|---|---|
committer | Alex Martelli <aleaxit@gmail.com> | 2007-08-22 22:39:42 (GMT) |
commit | 86d8b3497fb509d1c52f6f29f74854ec96987f23 (patch) | |
tree | f7224a765686a781615ff73e3393f6bd106e1171 /Lib | |
parent | a62b45c95daa1172c7411062372f0cc3827a292f (diff) | |
download | cpython-86d8b3497fb509d1c52f6f29f74854ec96987f23.zip cpython-86d8b3497fb509d1c52f6f29f74854ec96987f23.tar.gz cpython-86d8b3497fb509d1c52f6f29f74854ec96987f23.tar.bz2 |
Implement the trunc builtin for PEP 3141
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_builtin.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py index b3e4733..d5fc85f 100644 --- a/Lib/test/test_builtin.py +++ b/Lib/test/test_builtin.py @@ -1515,6 +1515,20 @@ class BuiltinTest(unittest.TestCase): raise ValueError self.assertRaises(ValueError, sum, BadSeq()) + def test_trunc(self): + class TestTrunc: + def __trunc__(self): + return 23 + + class TestNoTrunc: + pass + + self.assertEqual(trunc(TestTrunc()), 23) + + self.assertRaises(TypeError, trunc) + self.assertRaises(TypeError, trunc, 1, 2) + self.assertRaises(TypeError, trunc, TestNoTrunc()) + def test_tuple(self): self.assertEqual(tuple(()), ()) t0_3 = (0, 1, 2, 3) |