tests that attributes are polymorphic
(self)
| 679 | ) |
| 680 | |
| 681 | def test_inheritance(self): |
| 682 | """tests that attributes are polymorphic""" |
| 683 | |
| 684 | class Foo: |
| 685 | pass |
| 686 | |
| 687 | class Bar(Foo): |
| 688 | pass |
| 689 | |
| 690 | instrumentation.register_class(Foo) |
| 691 | instrumentation.register_class(Bar) |
| 692 | |
| 693 | def func1(state, passive): |
| 694 | return "this is the foo attr" |
| 695 | |
| 696 | def func2(state, passive): |
| 697 | return "this is the bar attr" |
| 698 | |
| 699 | def func3(state, passive): |
| 700 | return "this is the shared attr" |
| 701 | |
| 702 | _register_attribute( |
| 703 | Foo, "element", uselist=False, callable_=func1, useobject=True |
| 704 | ) |
| 705 | _register_attribute( |
| 706 | Foo, "element2", uselist=False, callable_=func3, useobject=True |
| 707 | ) |
| 708 | _register_attribute( |
| 709 | Bar, "element", uselist=False, callable_=func2, useobject=True |
| 710 | ) |
| 711 | |
| 712 | x = Foo() |
| 713 | y = Bar() |
| 714 | assert x.element == "this is the foo attr" |
| 715 | assert y.element == "this is the bar attr" |
| 716 | assert x.element2 == "this is the shared attr" |
| 717 | assert y.element2 == "this is the shared attr" |
| 718 | |
| 719 | def test_no_double_state(self): |
| 720 | states = set() |
nothing calls this directly
no test coverage detected