MCPcopy Index your code
hub / github.com/msgspec/msgspec / test_post_init

Method test_post_init

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

Source from the content-addressed store, hash-verified

2610
2611class TestPostInit:
2612 def test_post_init(self):
2613 called = False
2614 singleton = object()
2615
2616 class Ex(Struct):
2617 x: int
2618
2619 def __post_init__(self):
2620 nonlocal called
2621 called = True
2622 return singleton
2623
2624 Ex(1)
2625 assert called
2626 # Return value is decref'd
2627 assert sys.getrefcount(singleton) <= 2 # 1 for ref, 1 for call
2628
2629 def test_post_init_errors(self):
2630 class Ex(Struct):

Callers

nothing calls this directly

Calls 1

ExClass · 0.70

Tested by

no test coverage detected