-
Notifications
You must be signed in to change notification settings - Fork 5
/
inline_base_test.py
61 lines (55 loc) · 2.09 KB
/
inline_base_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import pyinline_base as m
def test_inline_base():
obj = m.Derived()
assert isinstance(obj, m.Derived)
assert obj.member_function() == 42
classes = [c.__name__ for c in m.Derived.mro()]
assert "Derived" in classes
assert not "Base" in classes
def test_derived_multiple():
obj = m.DerivedMultiple()
assert isinstance(obj, m.DerivedMultiple)
assert isinstance(obj, m.OtherBase)
assert obj.member_function() == 42
assert obj.from_other_base() is True
classes = [c.__name__ for c in m.DerivedMultiple.mro()]
assert "DerivedMultiple" in classes
assert not "Base" in classes
assert "OtherBase" in classes
def test_derived_derived():
obj = m.DerivedDerived()
assert isinstance(obj, m.DerivedDerived)
assert obj.member_function() == 42
classes = [c.__name__ for c in m.DerivedDerived.mro()]
assert "DerivedDerived" in classes
assert "Derived" in classes
assert not "Base" in classes
def test_derived_derived_multiple():
obj = m.DerivedDerivedMultiple()
assert isinstance(obj, m.DerivedDerivedMultiple)
assert isinstance(obj, m.OtherBase)
assert obj.member_function() == 42
assert obj.from_other_base() is True
classes = [c.__name__ for c in m.DerivedDerivedMultiple.mro()]
assert "DerivedDerivedMultiple" in classes
assert "Derived" in classes
assert not "Base" in classes
assert "OtherBase" in classes
def test_derived_indirect():
obj = m.DerivedIndirect()
assert isinstance(obj, m.DerivedIndirect)
assert obj.member_function() == 42
assert obj.from_indirect() is True
classes = [c.__name__ for c in m.DerivedIndirect.mro()]
assert "DerivedIndirect" in classes
assert not "Base" in classes
assert not "Indirect" in classes
def test_derived_indirect_hide():
obj = m.DerivedHide()
assert isinstance(obj, m.DerivedHide)
assert not hasattr(obj, "member_function")
assert not hasattr(obj, "from_indirect")
classes = [c.__name__ for c in m.DerivedHide.mro()]
assert "DerivedHide" in classes
assert not "Base" in classes
assert not "Indirect" in classes