diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2010-05-25 19:06:24 (GMT) |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2010-05-25 19:06:24 (GMT) |
commit | fb3dc94b8c84b91a384c0159c7b126976cbc79fd (patch) | |
tree | fcb25463f2542344c70da29ce49198529cf347d1 /Lib/test/test_builtin.py | |
parent | f5077aa17bc0bcae14524e25cff6635c9398fd57 (diff) | |
download | cpython-fb3dc94b8c84b91a384c0159c7b126976cbc79fd.zip cpython-fb3dc94b8c84b91a384c0159c7b126976cbc79fd.tar.gz cpython-fb3dc94b8c84b91a384c0159c7b126976cbc79fd.tar.bz2 |
Merged revisions 81525 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r81525 | mark.dickinson | 2010-05-25 20:01:08 +0100 (Tue, 25 May 2010) | 3 lines
Issue #8816: Extra tests for some built-in functions. These tests are
ports of IronPython tests. Thanks Gregory Nofi.
........
Diffstat (limited to 'Lib/test/test_builtin.py')
-rw-r--r-- | Lib/test/test_builtin.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py index 94c6878..3f412b7 100644 --- a/Lib/test/test_builtin.py +++ b/Lib/test/test_builtin.py @@ -124,6 +124,16 @@ class BuiltinTest(unittest.TestCase): self.assertEqual(abs(-3.14), 3.14) # str self.assertRaises(TypeError, abs, 'a') + # bool + self.assertEqual(abs(True), 1) + self.assertEqual(abs(False), 0) + # other + self.assertRaises(TypeError, abs) + self.assertRaises(TypeError, abs, None) + class AbsClass(object): + def __abs__(self): + return -5 + self.assertEqual(abs(AbsClass()), -5) def test_all(self): self.assertEqual(all([2, 4, 6]), True) @@ -600,6 +610,8 @@ class BuiltinTest(unittest.TestCase): def __len__(self): return sys.maxsize + 1 self.assertRaises(OverflowError, len, HugeLen()) + class NoLenMethod(object): pass + self.assertRaises(TypeError, len, NoLenMethod()) def test_map(self): self.assertEqual( @@ -1187,6 +1199,11 @@ class BuiltinTest(unittest.TestCase): b = 2 return vars() + class C_get_vars(object): + def getDict(self): + return {'a':2} + __dict__ = property(fget=getDict) + def test_vars(self): self.assertEqual(set(vars()), set(dir())) import sys @@ -1195,6 +1212,7 @@ class BuiltinTest(unittest.TestCase): self.assertEqual(self.get_vars_f2(), {'a': 1, 'b': 2}) self.assertRaises(TypeError, vars, 42, 42) self.assertRaises(TypeError, vars, 42) + self.assertEqual(vars(self.C_get_vars()), {'a':2}) def test_zip(self): a = (1, 2, 3) |