()
| 112 | |
| 113 | |
| 114 | def test_struct_instance_attributes(): |
| 115 | class Test(Struct): |
| 116 | c: int |
| 117 | b: float |
| 118 | a: str = "hello" |
| 119 | |
| 120 | x = Test(1, 2.0, a="goodbye") |
| 121 | |
| 122 | assert x.__struct_fields__ == ("c", "b", "a") |
| 123 | assert x.__struct_encode_fields__ == ("c", "b", "a") |
| 124 | assert x.__struct_fields__ is x.__struct_encode_fields__ |
| 125 | assert x.__struct_defaults__ == ("hello",) |
| 126 | assert x.__slots__ == ("a", "b", "c") |
| 127 | assert isinstance(x.__struct_config__, StructConfig) |
| 128 | |
| 129 | assert x.c == 1 |
| 130 | assert x.b == 2.0 |
| 131 | assert x.a == "goodbye" |
| 132 | |
| 133 | |
| 134 | def test_struct_subclass_forbids_init_new_slots(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…