Changes work.
(self, C, data)
| 685 | |
| 686 | @given(simple_classes(), st.data()) |
| 687 | def test_change(self, C, data): |
| 688 | """ |
| 689 | Changes work. |
| 690 | """ |
| 691 | # Take the first attribute, and change it. |
| 692 | assume(fields(C)) # Skip classes with no attributes. |
| 693 | field_names = [a.name for a in fields(C)] |
| 694 | original = C() |
| 695 | chosen_names = data.draw(st.sets(st.sampled_from(field_names))) |
| 696 | # We pay special attention to private attributes, they should behave |
| 697 | # like in `__init__`. |
| 698 | change_dict = { |
| 699 | name.replace("_", ""): data.draw(st.integers()) |
| 700 | for name in chosen_names |
| 701 | } |
| 702 | changed = evolve(original, **change_dict) |
| 703 | for name in chosen_names: |
| 704 | assert getattr(changed, name) == change_dict[name.replace("_", "")] |
| 705 | |
| 706 | @given(simple_classes()) |
| 707 | def test_unknown(self, C): |