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

Method test_defstruct_fields

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

Source from the content-addressed store, hash-verified

2126 assert as_tuple(Empty()) == ()
2127
2128 def test_defstruct_fields(self):
2129 Test = defstruct("Point", ["x", ("y", int), ("z", int, 0)])
2130 assert Test.__struct_fields__ == ("x", "y", "z")
2131 assert Test.__struct_defaults__ == (0,)
2132 assert Test.__annotations__ == {"x": Any, "y": int, "z": int}
2133 assert as_tuple(Test(1, 2)) == (1, 2, 0)
2134 assert as_tuple(Test(1, 2, 3)) == (1, 2, 3)
2135
2136 def test_defstruct_fields_iterable(self):
2137 Test = defstruct("Point", ((n, int) for n in "xyz"))

Callers

nothing calls this directly

Calls 2

as_tupleFunction · 0.85
TestClass · 0.70

Tested by

no test coverage detected