diff options
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_weakset.py | 5 | ||||
-rw-r--r-- | Lib/weakref.py | 3 |
2 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_weakset.py b/Lib/test/test_weakset.py index 569facd..49a9b5c 100644 --- a/Lib/test/test_weakset.py +++ b/Lib/test/test_weakset.py @@ -2,6 +2,7 @@ import unittest from weakref import WeakSet import string from collections import UserString as ustr +from collections.abc import Set, MutableSet import gc import contextlib @@ -437,6 +438,10 @@ class TestWeakSet(unittest.TestCase): def test_repr(self): assert repr(self.s) == repr(self.s.data) + def test_abc(self): + self.assertIsInstance(self.s, Set) + self.assertIsInstance(self.s, MutableSet) + if __name__ == "__main__": unittest.main() diff --git a/Lib/weakref.py b/Lib/weakref.py index d17b3ed..e3c2ce2 100644 --- a/Lib/weakref.py +++ b/Lib/weakref.py @@ -33,6 +33,9 @@ __all__ = ["ref", "proxy", "getweakrefcount", "getweakrefs", "WeakSet", "WeakMethod", "finalize"] +_collections_abc.Set.register(WeakSet) +_collections_abc.MutableSet.register(WeakSet) + class WeakMethod(ref): """ A custom `weakref.ref` subclass which simulates a weak reference to |