diff options
Diffstat (limited to 'Lib/test/test_descr.py')
-rw-r--r-- | Lib/test/test_descr.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py index 707c931..791cf71 100644 --- a/Lib/test/test_descr.py +++ b/Lib/test/test_descr.py @@ -4923,6 +4923,23 @@ order (MRO) for bases """ cls.lst = [2**i for i in range(10000)] X.descr + def test_remove_subclass(self): + # bpo-46417: when the last subclass of a type is deleted, + # remove_subclass() clears the internal dictionary of subclasses: + # set PyTypeObject.tp_subclasses to NULL. remove_subclass() is called + # when a type is deallocated. + class Parent: + pass + self.assertEqual(Parent.__subclasses__(), []) + + class Child(Parent): + pass + self.assertEqual(Parent.__subclasses__(), [Child]) + + del Child + gc.collect() + self.assertEqual(Parent.__subclasses__(), []) + class DictProxyTests(unittest.TestCase): def setUp(self): |