| 1856 | self.assertEqual(sys.getsizeof(obj), expected) |
| 1857 | |
| 1858 | def test_slots(self): |
| 1859 | # check all subclassable types defined in Objects/ that allow |
| 1860 | # non-empty __slots__ |
| 1861 | check = self.check_slots |
| 1862 | class BA(bytearray): |
| 1863 | __slots__ = 'a', 'b', 'c' |
| 1864 | check(BA(), bytearray(), '3P') |
| 1865 | class D(dict): |
| 1866 | __slots__ = 'a', 'b', 'c' |
| 1867 | check(D(x=[]), {'x': []}, '3P') |
| 1868 | class L(list): |
| 1869 | __slots__ = 'a', 'b', 'c' |
| 1870 | check(L(), [], '3P') |
| 1871 | class S(set): |
| 1872 | __slots__ = 'a', 'b', 'c' |
| 1873 | check(S(), set(), '3P') |
| 1874 | class FS(frozenset): |
| 1875 | __slots__ = 'a', 'b', 'c' |
| 1876 | check(FS(), frozenset(), '3P') |
| 1877 | from collections import OrderedDict |
| 1878 | class OD(OrderedDict): |
| 1879 | __slots__ = 'a', 'b', 'c' |
| 1880 | check(OD(x=[]), OrderedDict(x=[]), '3P') |
| 1881 | |
| 1882 | def test_pythontypes(self): |
| 1883 | # check all types defined in Python/ |