Test dumping to dicts and back for Hypothesis-generated classes. Private attributes don't round-trip (the attribute name is different than the initializer argument).
(self, cls, dict_class)
| 193 | |
| 194 | @given(simple_classes(private_attrs=False), st.sampled_from(MAPPING_TYPES)) |
| 195 | def test_roundtrip(self, cls, dict_class): |
| 196 | """ |
| 197 | Test dumping to dicts and back for Hypothesis-generated classes. |
| 198 | |
| 199 | Private attributes don't round-trip (the attribute name is different |
| 200 | than the initializer argument). |
| 201 | """ |
| 202 | instance = cls() |
| 203 | dict_instance = asdict(instance, dict_factory=dict_class) |
| 204 | |
| 205 | assert isinstance(dict_instance, dict_class) |
| 206 | |
| 207 | roundtrip_instance = cls(**dict_instance) |
| 208 | |
| 209 | assert instance == roundtrip_instance |
| 210 | |
| 211 | @given(simple_classes()) |
| 212 | def test_asdict_preserve_order(self, cls): |