MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_slots

Method test_slots

Lib/test/test_sys.py:1858–1880  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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/

Callers

nothing calls this directly

Calls 9

OrderedDictClass · 0.90
BAClass · 0.85
setFunction · 0.85
ODClass · 0.85
checkFunction · 0.70
DClass · 0.70
LClass · 0.70
SClass · 0.70
FSClass · 0.70

Tested by

no test coverage detected