MCPcopy Create free account
hub / github.com/apache/arrow / test_roundtrip_schema_capsule

Function test_roundtrip_schema_capsule

python/pyarrow/tests/test_cffi.py:578–594  ·  view source on GitHub ↗
(obj)

Source from the content-addressed store, hash-verified

576 pa.schema({'foo': pa.int32()})],
577 ids=['type', 'field', 'schema'])
578def test_roundtrip_schema_capsule(obj):
579 gc.collect() # Make sure no Arrow data dangles in a ref cycle
580 old_allocated = pa.total_allocated_bytes()
581
582 capsule = obj.__arrow_c_schema__()
583 assert PyCapsule_IsValid(capsule, b"arrow_schema") == 1
584 assert pa.total_allocated_bytes() > old_allocated
585 obj_out = type(obj)._import_from_c_capsule(capsule)
586 assert obj_out == obj
587
588 assert pa.total_allocated_bytes() == old_allocated
589
590 capsule = obj.__arrow_c_schema__()
591
592 assert pa.total_allocated_bytes() > old_allocated
593 del capsule
594 assert pa.total_allocated_bytes() == old_allocated
595
596
597@pytest.mark.parametrize('arr,schema_accessor,bad_type,good_type', [

Callers

nothing calls this directly

Calls 3

PyCapsule_IsValidFunction · 0.70
typeEnum · 0.50
__arrow_c_schema__Method · 0.45

Tested by

no test coverage detected