| 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")) |