MCPcopy
hub / github.com/msgspec/msgspec / test_mixin_nonempty_slots

Method test_mixin_nonempty_slots

tests/unit/test_struct.py:218–236  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

216 assert Test2.__weakrefoffset__ != 0
217
218 def test_mixin_nonempty_slots(self):
219 class Mixin(object):
220 __slots__ = "_state"
221
222 def method(self):
223 try:
224 return self._state
225 except AttributeError:
226 self._state = self.x + 1
227 return self._state
228
229 class Test(Struct, Mixin):
230 x: int
231
232 assert Test.__dictoffset__ == 0
233
234 t = Test(1)
235 assert t.method() == 2
236 assert t.method() == 2
237
238 def test_mixin_forbids_init(self):
239 class Mixin(object):

Callers

nothing calls this directly

Calls 2

methodMethod · 0.80
TestClass · 0.70

Tested by

no test coverage detected