summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorArmin Rigo <arigo@tunes.org>2005-11-07 08:38:00 (GMT)
committerArmin Rigo <arigo@tunes.org>2005-11-07 08:38:00 (GMT)
commitc6686b7c7e0a10e7dc472a0256a9823c4d7136f2 (patch)
tree9acfea79c7c8617efa89d3ef74417e8308a6ca69 /Lib
parent64b414ad4c7e28eef515aff25088542f09c4d2a0 (diff)
downloadcpython-c6686b7c7e0a10e7dc472a0256a9823c4d7136f2.zip
cpython-c6686b7c7e0a10e7dc472a0256a9823c4d7136f2.tar.gz
cpython-c6686b7c7e0a10e7dc472a0256a9823c4d7136f2.tar.bz2
Added proper reflection on instances of <type 'method-wrapper'>, e.g.
'[].__add__', to match what the other internal descriptor types provide: '__objclass__' attribute, '__self__' member, and reasonable repr and comparison. Added a test.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_descr.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index 05fd72e..f594ca8 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -3977,6 +3977,18 @@ def test_init():
else:
raise TestFailed, "did not test __init__() for None return"
+def methodwrapper():
+ # <type 'method-wrapper'> did not support any reflection before 2.5
+ if verbose:
+ print "Testing method-wrapper objects..."
+
+ l = []
+ vereq(l.__add__, l.__add__)
+ verify(l.__add__ != [].__add__)
+ verify(l.__add__.__name__ == '__add__')
+ verify(l.__add__.__self__ is l)
+ verify(l.__add__.__objclass__ is list)
+ vereq(l.__add__.__doc__, list.__add__.__doc__)
def test_main():
weakref_segfault() # Must be first, somehow
@@ -4071,6 +4083,7 @@ def test_main():
filefault()
vicious_descriptor_nonsense()
test_init()
+ methodwrapper()
if verbose: print "All OK"