(self)
| 2723 | assert control == list(p.children) |
| 2724 | |
| 2725 | def test_custom(self): |
| 2726 | someothertable, sometable = ( |
| 2727 | self.tables.someothertable, |
| 2728 | self.tables.sometable, |
| 2729 | ) |
| 2730 | |
| 2731 | class Parent: |
| 2732 | pass |
| 2733 | |
| 2734 | class Child: |
| 2735 | pass |
| 2736 | |
| 2737 | class MyCollection: |
| 2738 | def __init__(self): |
| 2739 | self.data = [] |
| 2740 | |
| 2741 | @collection.appender |
| 2742 | def append(self, value): |
| 2743 | self.data.append(value) |
| 2744 | |
| 2745 | @collection.remover |
| 2746 | def remove(self, value): |
| 2747 | self.data.remove(value) |
| 2748 | |
| 2749 | @collection.iterator |
| 2750 | def __iter__(self): |
| 2751 | return iter(self.data) |
| 2752 | |
| 2753 | self.mapper_registry.map_imperatively( |
| 2754 | Parent, |
| 2755 | sometable, |
| 2756 | properties={ |
| 2757 | "children": relationship(Child, collection_class=MyCollection) |
| 2758 | }, |
| 2759 | ) |
| 2760 | self.mapper_registry.map_imperatively(Child, someothertable) |
| 2761 | |
| 2762 | control = list() |
| 2763 | p1 = Parent() |
| 2764 | |
| 2765 | o = Child() |
| 2766 | control.append(o) |
| 2767 | p1.children.append(o) |
| 2768 | assert control == list(p1.children) |
| 2769 | |
| 2770 | o = Child() |
| 2771 | control.append(o) |
| 2772 | p1.children.append(o) |
| 2773 | assert control == list(p1.children) |
| 2774 | |
| 2775 | o = Child() |
| 2776 | control.append(o) |
| 2777 | p1.children.append(o) |
| 2778 | assert control == list(p1.children) |
| 2779 | |
| 2780 | sess = fixture_session() |
| 2781 | sess.add(p1) |
| 2782 | sess.flush() |
nothing calls this directly
no test coverage detected