diff options
author | Benjamin Peterson <benjamin@python.org> | 2009-02-08 21:07:20 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2009-02-08 21:07:20 (GMT) |
commit | ee1ae7ccb76b9ae81ae2c4e9c04ce71d7b605038 (patch) | |
tree | fad412f4e8eb7f6e84423980ec2830923e43badd /Lib/test/test_builtin.py | |
parent | c7055a59a6c7f39e19c0936ff9f48a5c6924fc4f (diff) | |
download | cpython-ee1ae7ccb76b9ae81ae2c4e9c04ce71d7b605038.zip cpython-ee1ae7ccb76b9ae81ae2c4e9c04ce71d7b605038.tar.gz cpython-ee1ae7ccb76b9ae81ae2c4e9c04ce71d7b605038.tar.bz2 |
fix len() when __len__() returns a non number type #5137
Diffstat (limited to 'Lib/test/test_builtin.py')
-rw-r--r-- | Lib/test/test_builtin.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py index 0aa0d52..a62e124 100644 --- a/Lib/test/test_builtin.py +++ b/Lib/test/test_builtin.py @@ -611,6 +611,18 @@ class BuiltinTest(unittest.TestCase): def __len__(self): raise ValueError self.assertRaises(ValueError, len, BadSeq()) + class InvalidLen: + def __len__(self): + return None + self.assertRaises(TypeError, len, InvalidLen()) + class FloatLen: + def __len__(self): + return 4.5 + self.assertRaises(TypeError, len, FloatLen()) + class HugeLen: + def __len__(self): + return sys.maxsize + 1 + self.assertRaises(OverflowError, len, HugeLen()) def test_map(self): self.assertEqual( |