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

Method test_replace_gc_delayed_tracking

tests/unit/test_struct.py:2328–2342  ·  view source on GitHub ↗
(self, replace)

Source from the content-addressed store, hash-verified

2326 assert replace(Test(1, 2), x=3) == Test(3, 2)
2327
2328 def test_replace_gc_delayed_tracking(self, replace):
2329 class Test(msgspec.Struct):
2330 x: int
2331 y: Optional[List[int]]
2332
2333 obj = Test(1, None)
2334 assert not gc.is_tracked(replace(obj))
2335 assert not gc.is_tracked(replace(obj, x=10))
2336 assert not gc.is_tracked(replace(obj, y=None))
2337 assert gc.is_tracked(replace(obj, y=[1, 2, 3]))
2338
2339 obj = Test(1, [1, 2, 3])
2340 assert gc.is_tracked(replace(obj))
2341 assert gc.is_tracked(replace(obj, x=1))
2342 assert not gc.is_tracked(replace(obj, y=None))
2343
2344 def test_replace_gc_false(self, replace):
2345 class Test(msgspec.Struct, gc=False):

Callers

nothing calls this directly

Calls 2

replaceFunction · 0.85
TestClass · 0.70

Tested by

no test coverage detected