diff options
author | Armin Rigo <arigo@tunes.org> | 2005-11-07 08:38:00 (GMT) |
---|---|---|
committer | Armin Rigo <arigo@tunes.org> | 2005-11-07 08:38:00 (GMT) |
commit | c6686b7c7e0a10e7dc472a0256a9823c4d7136f2 (patch) | |
tree | 9acfea79c7c8617efa89d3ef74417e8308a6ca69 /Lib/test/test_descr.py | |
parent | 64b414ad4c7e28eef515aff25088542f09c4d2a0 (diff) | |
download | cpython-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/test/test_descr.py')
-rw-r--r-- | Lib/test/test_descr.py | 13 |
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" |