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

Function test_extract_class_dict

tests/cloudpickle_test.py:90–120  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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