(self)
| 5756 | |
| 5757 | @support.cpython_only |
| 5758 | def test_subclasses(self): |
| 5759 | # Verify that subclasses can share keys (per PEP 412) |
| 5760 | class A: |
| 5761 | pass |
| 5762 | class B(A): |
| 5763 | pass |
| 5764 | |
| 5765 | #Shrink keys by repeatedly creating instances |
| 5766 | [(A(), B()) for _ in range(30)] |
| 5767 | |
| 5768 | a, b = A(), B() |
| 5769 | self.assertEqual(sys.getsizeof(vars(a)), sys.getsizeof(vars(b))) |
| 5770 | self.assertLess(sys.getsizeof(vars(a)), sys.getsizeof({"a":1})) |
| 5771 | # Initial hash table can contain only one or two elements. |
| 5772 | # Set 6 attributes to cause internal resizing. |
| 5773 | a.x, a.y, a.z, a.w, a.v, a.u = range(6) |
| 5774 | self.assertNotEqual(sys.getsizeof(vars(a)), sys.getsizeof(vars(b))) |
| 5775 | a2 = A() |
| 5776 | self.assertGreater(sys.getsizeof(vars(a)), sys.getsizeof(vars(a2))) |
| 5777 | self.assertLess(sys.getsizeof(vars(a2)), sys.getsizeof({"a":1})) |
| 5778 | self.assertLess(sys.getsizeof(vars(b)), sys.getsizeof({"a":1})) |
| 5779 | |
| 5780 | |
| 5781 | class DebugHelperMeta(type): |
nothing calls this directly
no test coverage detected