summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_descr.py
diff options
context:
space:
mode:
authorArmin Rigo <arigo@tunes.org>2006-06-08 10:56:24 (GMT)
committerArmin Rigo <arigo@tunes.org>2006-06-08 10:56:24 (GMT)
commitfd01d7933bc3e9fd64d81961fbb7eabddcc82bc3 (patch)
tree04841c9342f5a07bd7436f8520aa2d54f0e54580 /Lib/test/test_descr.py
parent996710fd44426f43d54034ebf3ee2355fca18f6a (diff)
downloadcpython-fd01d7933bc3e9fd64d81961fbb7eabddcc82bc3.zip
cpython-fd01d7933bc3e9fd64d81961fbb7eabddcc82bc3.tar.gz
cpython-fd01d7933bc3e9fd64d81961fbb7eabddcc82bc3.tar.bz2
(arre, arigo) SF bug #1350060
Give a consistent behavior for comparison and hashing of method objects (both user- and built-in methods). Now compares the 'self' recursively. The hash was already asking for the hash of 'self'.
Diffstat (limited to 'Lib/test/test_descr.py')
-rw-r--r--Lib/test/test_descr.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index 32796bf..ca91042 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -4014,11 +4014,24 @@ def methodwrapper():
l = []
vereq(l.__add__, l.__add__)
- verify(l.__add__ != [].__add__)
+ vereq(l.__add__, [].__add__)
+ verify(l.__add__ != [5].__add__)
+ verify(l.__add__ != l.__mul__)
verify(l.__add__.__name__ == '__add__')
verify(l.__add__.__self__ is l)
verify(l.__add__.__objclass__ is list)
vereq(l.__add__.__doc__, list.__add__.__doc__)
+ try:
+ hash(l.__add__)
+ except TypeError:
+ pass
+ else:
+ raise TestFailed("no TypeError from hash([].__add__)")
+
+ t = ()
+ t += (7,)
+ vereq(t.__add__, (7,).__add__)
+ vereq(hash(t.__add__), hash((7,).__add__))
def notimplemented():
# all binary methods should be able to return a NotImplemented