summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_descr.py
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2009-05-09 18:15:04 (GMT)
committerBenjamin Peterson <benjamin@python.org>2009-05-09 18:15:04 (GMT)
commita5758c012001b1044d4a109b736c0406cdf8c9ec (patch)
tree562f1c9b048ce5812de50b67cee59707d5625fbb /Lib/test/test_descr.py
parent8bc5b681599b66887f69ca54631d6e1ce4894252 (diff)
downloadcpython-a5758c012001b1044d4a109b736c0406cdf8c9ec.zip
cpython-a5758c012001b1044d4a109b736c0406cdf8c9ec.tar.gz
cpython-a5758c012001b1044d4a109b736c0406cdf8c9ec.tar.bz2
Merged revisions 72508 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r72508 | benjamin.peterson | 2009-05-09 11:36:39 -0500 (Sat, 09 May 2009) | 1 line convert some more special methods to use _PyObject_LookupSpecial ........
Diffstat (limited to 'Lib/test/test_descr.py')
-rw-r--r--Lib/test/test_descr.py18
1 files changed, 15 insertions, 3 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index b4bd948..afb0f87 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -1,4 +1,5 @@
import builtins
+import sys
import types
import unittest
import warnings
@@ -1551,13 +1552,20 @@ order (MRO) for bases """
return b"hello"
def empty_seq(self):
return []
+ def zero(self):
+ return 0
+ def stop(self):
+ raise StopIteration
# It would be nice to have every special method tested here, but I'm
# only listing the ones I can remember outside of typeobject.c, since it
# does it right.
specials = [
- ("__bytes__", bytes, hello),
- ("__reversed__", reversed, empty_seq),
+ ("__bytes__", bytes, hello, {}),
+ ("__reversed__", reversed, empty_seq, {}),
+ ("__length_hint__", list, zero,
+ {"__iter__" : iden, "__next__" : stop}),
+ ("__sizeof__", sys.getsizeof, zero, {}),
# These two fail because the compiler generates LOAD_ATTR to look
# them up. We'd have to add a new opcode to fix this, and it's
# probably not worth it.
@@ -1578,15 +1586,19 @@ order (MRO) for bases """
return self.impl.__get__(obj, owner)
- for name, runner, meth_impl in specials:
+ for name, runner, meth_impl, env in specials:
class X(Checker):
pass
+ for attr, obj in env.items():
+ setattr(X, attr, obj)
setattr(X, name, meth_impl)
runner(X())
record = []
class X(Checker):
pass
+ for attr, obj in env.items():
+ setattr(X, attr, obj)
setattr(X, name, SpecialDescr(meth_impl))
runner(X())
self.assertEqual(record, [1], name)