summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2009-05-09 16:36:39 (GMT)
committerBenjamin Peterson <benjamin@python.org>2009-05-09 16:36:39 (GMT)
commitaf1692a266d5c83d9367557f9642bbd618066318 (patch)
treeb2b3628e8868a81e6b1b23fb330c1887529c7214 /Lib/test
parentf9b01fe692515eabf555bbc40b458b195f46a807 (diff)
downloadcpython-af1692a266d5c83d9367557f9642bbd618066318.zip
cpython-af1692a266d5c83d9367557f9642bbd618066318.tar.gz
cpython-af1692a266d5c83d9367557f9642bbd618066318.tar.bz2
convert some more special methods to use _PyObject_LookupSpecial
Diffstat (limited to 'Lib/test')
-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 fe4eaea..e66b550 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -1,4 +1,5 @@
import __builtin__
+import sys
import types
import unittest
import warnings
@@ -1678,13 +1679,20 @@ order (MRO) for bases """
return "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 = [
- ("__unicode__", unicode, hello),
- ("__reversed__", reversed, empty_seq),
+ ("__unicode__", unicode, 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.
@@ -1705,15 +1713,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.iteritems():
+ setattr(X, attr, obj)
setattr(X, name, meth_impl)
runner(X())
record = []
class X(Checker):
pass
+ for attr, obj in env.iteritems():
+ setattr(X, attr, obj)
setattr(X, name, SpecialDescr(meth_impl))
runner(X())
self.assertEqual(record, [1], name)