summaryrefslogtreecommitdiff
path: root/Lib/test/test_augassign.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@dropbox.com>2016-08-18 09:22:23 -0700
committerGuido van Rossum <guido@dropbox.com>2016-08-18 09:22:23 -0700
commit97c1adf3935234da716d3289b85f72dcd67e90c2 (patch)
tree0af6f9f258cf26ee9e59db463cc89d04c45bc0b8 /Lib/test/test_augassign.py
parent0a6996d87d19a524c2a11dd315d96d12083c47d4 (diff)
downloadcpython-git-97c1adf3935234da716d3289b85f72dcd67e90c2.tar.gz
Anti-registration of various ABC methods.
- Issue #25958: Support "anti-registration" of special methods from various ABCs, like __hash__, __iter__ or __len__. All these (and several more) can be set to None in an implementation class and the behavior will be as if the method is not defined at all. (Previously, this mechanism existed only for __hash__, to make mutable classes unhashable.) Code contributed by Andrew Barnert and Ivan Levkivskyi.
Diffstat (limited to 'Lib/test/test_augassign.py')
-rw-r--r--Lib/test/test_augassign.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_augassign.py b/Lib/test/test_augassign.py
index 5093e9d0f3..5930d9e7a2 100644
--- a/Lib/test/test_augassign.py
+++ b/Lib/test/test_augassign.py
@@ -83,6 +83,10 @@ class AugAssignTest(unittest.TestCase):
def __iadd__(self, val):
return aug_test3(self.val + val)
+ class aug_test4(aug_test3):
+ """Blocks inheritance, and fallback to __add__"""
+ __iadd__ = None
+
x = aug_test(1)
y = x
x += 10
@@ -106,6 +110,10 @@ class AugAssignTest(unittest.TestCase):
self.assertTrue(y is not x)
self.assertEqual(x.val, 13)
+ x = aug_test4(4)
+ with self.assertRaises(TypeError):
+ x += 10
+
def testCustomMethods2(test_self):
output = []