| 718 | self.assert_(getattr(ListIsh, "_sa_instrumented") == id(ListIsh)) |
| 719 | |
| 720 | def _test_set_wo_mutation(self, typecallable, creator=None): |
| 721 | if creator is None: |
| 722 | creator = self.entity_maker |
| 723 | |
| 724 | class Foo: |
| 725 | pass |
| 726 | |
| 727 | canary = Canary() |
| 728 | instrumentation.register_class(Foo) |
| 729 | d = _register_attribute( |
| 730 | Foo, |
| 731 | "attr", |
| 732 | uselist=True, |
| 733 | typecallable=typecallable, |
| 734 | useobject=True, |
| 735 | ) |
| 736 | canary.listen(d) |
| 737 | |
| 738 | obj = Foo() |
| 739 | |
| 740 | e = creator() |
| 741 | |
| 742 | obj.attr.add(e) |
| 743 | |
| 744 | assert e in canary.added |
| 745 | assert e not in canary.appended_wo_mutation |
| 746 | |
| 747 | obj.attr.add(e) |
| 748 | assert e in canary.added |
| 749 | assert e in canary.appended_wo_mutation |
| 750 | |
| 751 | e = creator() |
| 752 | |
| 753 | obj.attr.update({e}) |
| 754 | |
| 755 | assert e in canary.added |
| 756 | assert e not in canary.appended_wo_mutation |
| 757 | |
| 758 | obj.attr.update({e}) |
| 759 | assert e in canary.added |
| 760 | assert e in canary.appended_wo_mutation |
| 761 | |
| 762 | def _test_set(self, typecallable, creator=None): |
| 763 | if creator is None: |