test that the attribute manager can properly traverse the managed attributes of an object, if the object is of a descendant class with managed attributes in the parent class
(self)
| 736 | eq_(list(states)[0].obj(), b) |
| 737 | |
| 738 | def test_inheritance2(self): |
| 739 | """test that the attribute manager can properly traverse the |
| 740 | managed attributes of an object, if the object is of a |
| 741 | descendant class with managed attributes in the parent class""" |
| 742 | |
| 743 | class Foo: |
| 744 | pass |
| 745 | |
| 746 | class Bar(Foo): |
| 747 | pass |
| 748 | |
| 749 | class Element: |
| 750 | _state = True |
| 751 | |
| 752 | instrumentation.register_class(Foo) |
| 753 | instrumentation.register_class(Bar) |
| 754 | _register_attribute(Foo, "element", uselist=False, useobject=True) |
| 755 | el = Element() |
| 756 | x = Bar() |
| 757 | x.element = el |
| 758 | eq_( |
| 759 | attributes.get_state_history( |
| 760 | attributes.instance_state(x), "element" |
| 761 | ), |
| 762 | ([el], (), ()), |
| 763 | ) |
| 764 | attributes.instance_state(x)._commit_all(attributes.instance_dict(x)) |
| 765 | added, unchanged, deleted = attributes.get_state_history( |
| 766 | attributes.instance_state(x), "element" |
| 767 | ) |
| 768 | assert added == () |
| 769 | assert unchanged == [el] |
| 770 | |
| 771 | def test_lazyhistory(self): |
| 772 | """tests that history functions work with lazy-loading attributes""" |
nothing calls this directly
no test coverage detected