MCPcopy Create free account
hub / github.com/cloudpipe/cloudpickle / test_extract_class_dict

Function test_extract_class_dict

tests/cloudpickle_test.py:91–121  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

89
90
91def test_extract_class_dict():
92 class A(int):
93 """A docstring"""
94
95 def method(self):
96 return "a"
97
98 class B:
99 """B docstring"""
100
101 B_CONSTANT = 42
102
103 def method(self):
104 return "b"
105
106 class C(A, B):
107 C_CONSTANT = 43
108
109 def method_c(self):
110 return "c"
111
112 clsdict = _extract_class_dict(C)
113 expected_keys = ["C_CONSTANT", "__doc__", "method_c"]
114 # New attribute in Python 3.13 beta 1
115 # https://github.com/python/cpython/pull/118475
116 if sys.version_info >= (3, 13):
117 expected_keys.insert(2, "__firstlineno__")
118 assert list(clsdict.keys()) == expected_keys
119 assert clsdict["C_CONSTANT"] == 43
120 assert clsdict["__doc__"] is None
121 assert clsdict["method_c"](C()) == C().method_c()
122
123
124class CloudPickleTest(unittest.TestCase):

Callers

nothing calls this directly

Calls 3

_extract_class_dictFunction · 0.90
method_cMethod · 0.80
CClass · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…