(self)
| 803 | ) |
| 804 | |
| 805 | def test_parenttrack(self): |
| 806 | class Foo: |
| 807 | pass |
| 808 | |
| 809 | class Bar: |
| 810 | pass |
| 811 | |
| 812 | instrumentation.register_class(Foo) |
| 813 | instrumentation.register_class(Bar) |
| 814 | _register_attribute( |
| 815 | Foo, "element", uselist=False, trackparent=True, useobject=True |
| 816 | ) |
| 817 | _register_attribute( |
| 818 | Bar, "element", uselist=False, trackparent=True, useobject=True |
| 819 | ) |
| 820 | f1 = Foo() |
| 821 | f2 = Foo() |
| 822 | b1 = Bar() |
| 823 | b2 = Bar() |
| 824 | f1.element = b1 |
| 825 | b2.element = f2 |
| 826 | assert attributes.has_parent(Foo, b1, "element") |
| 827 | assert not attributes.has_parent(Foo, b2, "element") |
| 828 | assert not attributes.has_parent(Foo, f2, "element") |
| 829 | assert attributes.has_parent(Bar, f2, "element") |
| 830 | b2.element = None |
| 831 | assert not attributes.has_parent(Bar, f2, "element") |
| 832 | |
| 833 | # test that double assignment doesn't accidentally reset the |
| 834 | # 'parent' flag. |
| 835 | |
| 836 | b3 = Bar() |
| 837 | f4 = Foo() |
| 838 | b3.element = f4 |
| 839 | assert attributes.has_parent(Bar, f4, "element") |
| 840 | b3.element = f4 |
| 841 | assert attributes.has_parent(Bar, f4, "element") |
| 842 | |
| 843 | def test_descriptorattributes(self): |
| 844 | """changeset: 1633 broke ability to use ORM to map classes with |
nothing calls this directly
no test coverage detected