(self, listcls)
| 2579 | self._test_list(ListLike) |
| 2580 | |
| 2581 | def _test_list(self, listcls): |
| 2582 | someothertable, sometable = ( |
| 2583 | self.tables.someothertable, |
| 2584 | self.tables.sometable, |
| 2585 | ) |
| 2586 | |
| 2587 | class Parent: |
| 2588 | pass |
| 2589 | |
| 2590 | class Child: |
| 2591 | pass |
| 2592 | |
| 2593 | self.mapper_registry.map_imperatively( |
| 2594 | Parent, |
| 2595 | sometable, |
| 2596 | properties={ |
| 2597 | "children": relationship(Child, collection_class=listcls) |
| 2598 | }, |
| 2599 | ) |
| 2600 | self.mapper_registry.map_imperatively(Child, someothertable) |
| 2601 | |
| 2602 | control = list() |
| 2603 | p = Parent() |
| 2604 | |
| 2605 | o = Child() |
| 2606 | control.append(o) |
| 2607 | p.children.append(o) |
| 2608 | assert control == p.children |
| 2609 | assert control == list(p.children) |
| 2610 | |
| 2611 | o = [Child(), Child(), Child(), Child()] |
| 2612 | control.extend(o) |
| 2613 | p.children.extend(o) |
| 2614 | assert control == p.children |
| 2615 | assert control == list(p.children) |
| 2616 | |
| 2617 | assert control[0] == p.children[0] |
| 2618 | assert control[-1] == p.children[-1] |
| 2619 | assert control[1:3] == p.children[1:3] |
| 2620 | |
| 2621 | del control[1] |
| 2622 | del p.children[1] |
| 2623 | assert control == p.children |
| 2624 | assert control == list(p.children) |
| 2625 | |
| 2626 | o = [Child()] |
| 2627 | control[1:3] = o |
| 2628 | |
| 2629 | p.children[1:3] = o |
| 2630 | assert control == p.children |
| 2631 | assert control == list(p.children) |
| 2632 | |
| 2633 | o = [Child(), Child(), Child(), Child()] |
| 2634 | control[1:3] = o |
| 2635 | p.children[1:3] = o |
| 2636 | assert control == p.children |
| 2637 | assert control == list(p.children) |
| 2638 |
no test coverage detected