test/stubgen: fix SIGABRT/SIGSEGV issue temporarily when testing dummy.capnp

This commit is contained in:
2026-07-09 19:56:54 +08:00
parent 3fd1723b92
commit efaae42603
+16 -3
View File
@@ -95,9 +95,22 @@ class TestAddressBookStub:
assert ab.people is not None
# dummy.capnp runtime tests skipped — its annotation imports (c.capnp,
# c++.capnp) cause pycapnp's C++ SchemaParser to SIGABRT. The generated
# .pyi passes static type-checking and `capnp compile -opy` succeeds.
class TestDummyStub:
"""dummy.capnp — comprehensive test schema."""
def test_all_types_loads(self) -> None:
from pathlib import Path
parser = capnp.SchemaParser() # pyright: ignore[reportAttributeAccessIssue]
m = parser.load(str(Path(__file__).parent / "dummy.capnp"))
msg = m.TestAllTypes.new_message(textField="hello", int32Field=42)
assert msg.textField == "hello"
def test_unions(self) -> None:
from pathlib import Path
parser = capnp.SchemaParser() # pyright: ignore[reportAttributeAccessIssue]
m = parser.load(str(Path(__file__).parent / "dummy.capnp"))
u = m.TestUnion.new_message()
assert u is not None
# Note: multi/consumer.capnp cross-file import test skipped —