blob: c10298d7024066b829ddc9eca1f936d017317714 [file] [log] [blame]
Dean Moldovanbad17402016-11-20 21:21:54 +01001def test_multiple_inheritance_cpp():
Wenzel Jakob8e5dceb2016-09-11 20:00:40 +09002 from pybind11_tests import MIType
3
4 mt = MIType(3, 4)
5
6 assert mt.foo() == 3
7 assert mt.bar() == 4
8
9
Dean Moldovanbad17402016-11-20 21:21:54 +010010def test_multiple_inheritance_mix1():
Wenzel Jakob8e5dceb2016-09-11 20:00:40 +090011 from pybind11_tests import Base2
12
13 class Base1:
14 def __init__(self, i):
15 self.i = i
16
17 def foo(self):
18 return self.i
19
20 class MITypePy(Base1, Base2):
21 def __init__(self, i, j):
22 Base1.__init__(self, i)
23 Base2.__init__(self, j)
24
25 mt = MITypePy(3, 4)
26
27 assert mt.foo() == 3
28 assert mt.bar() == 4
29
30
Dean Moldovanbad17402016-11-20 21:21:54 +010031def test_multiple_inheritance_mix2():
Wenzel Jakob8e5dceb2016-09-11 20:00:40 +090032 from pybind11_tests import Base1
33
34 class Base2:
35 def __init__(self, i):
36 self.i = i
37
38 def bar(self):
39 return self.i
40
41 class MITypePy(Base1, Base2):
42 def __init__(self, i, j):
43 Base1.__init__(self, i)
44 Base2.__init__(self, j)
45
46 mt = MITypePy(3, 4)
47
48 assert mt.foo() == 3
49 assert mt.bar() == 4
50
51
Dean Moldovanbad17402016-11-20 21:21:54 +010052def test_multiple_inheritance_virtbase():
Wenzel Jakob8e5dceb2016-09-11 20:00:40 +090053 from pybind11_tests import Base12a, bar_base2a, bar_base2a_sharedptr
54
55 class MITypePy(Base12a):
56 def __init__(self, i, j):
57 Base12a.__init__(self, i, j)
58
59 mt = MITypePy(3, 4)
60 assert mt.bar() == 4
61 assert bar_base2a(mt) == 4
62 assert bar_base2a_sharedptr(mt) == 4