6 from pybind11_tests
import ConstructorStats
7 from pybind11_tests
import multiple_inheritance
as m
17 @pytest.mark.skipif(
"env.PYPY and env.PY2")
18 @pytest.mark.xfail(
"env.PYPY and not env.PY2")
21 def __init__(self, i):
27 class MITypePy(Base1, m.Base2):
28 def __init__(self, i, j):
29 Base1.__init__(self, i)
30 m.Base2.__init__(self, j)
40 def __init__(self, i):
46 class MITypePy(m.Base1, Base2):
47 def __init__(self, i, j):
48 m.Base1.__init__(self, i)
49 Base2.__init__(self, j)
57 @pytest.mark.skipif(
"env.PYPY and env.PY2")
58 @pytest.mark.xfail(
"env.PYPY and not env.PY2")
61 class MI1(m.Base1, m.Base2):
62 def __init__(self, i, j):
63 m.Base1.__init__(self, i)
64 m.Base2.__init__(self, j)
70 class MI2(B1, m.Base1, m.Base2):
71 def __init__(self, i, j):
73 m.Base1.__init__(self, i)
74 m.Base2.__init__(self, j)
77 def __init__(self, i, j):
78 MI2.__init__(self, i, j)
80 class MI4(MI3, m.Base2):
81 def __init__(self, i, j):
82 MI3.__init__(self, i, j)
84 m.Base2.__init__(self, i + 100)
86 class MI5(m.Base2, B1, m.Base1):
87 def __init__(self, i, j):
89 m.Base1.__init__(self, i)
90 m.Base2.__init__(self, j)
92 class MI6(m.Base2, B1):
93 def __init__(self, i):
94 m.Base2.__init__(self, i)
110 def __init__(self, i):
112 MI6.__init__(self, i)
115 def __init__(self, i):
116 MI6.__init__(self, i)
120 def __init__(self, i):
122 MI6.__init__(self, i)
125 assert mi1.foo() == 1
126 assert mi1.bar() == 2
130 assert mi2.foo() == 3
131 assert mi2.bar() == 4
135 assert mi3.foo() == 5
136 assert mi3.bar() == 6
140 assert mi4.foo() == 7
141 assert mi4.bar() == 8
145 assert mi5.foo() == 10
146 assert mi5.bar() == 11
150 assert mi6.bar() == 12
154 assert mi7.bar() == 13
158 assert mi8.bar() == 14
162 assert mi8b.bar() == 15
167 class MIMany14(m.BaseN1, m.BaseN2, m.BaseN3, m.BaseN4):
169 m.BaseN1.__init__(self, 1)
170 m.BaseN2.__init__(self, 2)
171 m.BaseN3.__init__(self, 3)
172 m.BaseN4.__init__(self, 4)
174 class MIMany58(m.BaseN5, m.BaseN6, m.BaseN7, m.BaseN8):
176 m.BaseN5.__init__(self, 5)
177 m.BaseN6.__init__(self, 6)
178 m.BaseN7.__init__(self, 7)
179 m.BaseN8.__init__(self, 8)
181 class MIMany916(m.BaseN9, m.BaseN10, m.BaseN11, m.BaseN12, m.BaseN13, m.BaseN14, m.BaseN15,
184 m.BaseN9.__init__(self, 9)
185 m.BaseN10.__init__(self, 10)
186 m.BaseN11.__init__(self, 11)
187 m.BaseN12.__init__(self, 12)
188 m.BaseN13.__init__(self, 13)
189 m.BaseN14.__init__(self, 14)
190 m.BaseN15.__init__(self, 15)
191 m.BaseN16.__init__(self, 16)
193 class MIMany19(MIMany14, MIMany58, m.BaseN9):
195 MIMany14.__init__(self)
196 MIMany58.__init__(self)
197 m.BaseN9.__init__(self, 9)
199 class MIMany117(MIMany14, MIMany58, MIMany916, m.BaseN17):
201 MIMany14.__init__(self)
202 MIMany58.__init__(self)
203 MIMany916.__init__(self)
204 m.BaseN17.__init__(self, 17)
208 for i
in range(1, 4):
213 for i
in range(9, 16):
218 for i
in range(1, 9):
223 for i
in range(1, 17):
229 class MITypePy(m.Base12a):
230 def __init__(self, i, j):
231 m.Base12a.__init__(self, i, j)
235 assert m.bar_base2a(mt) == 4
236 assert m.bar_base2a_sharedptr(mt) == 4
240 """Mixing bases with and without static properties should be possible 241 and the result should be independent of base definition order""" 243 for d
in (m.VanillaStaticMix1(), m.VanillaStaticMix2()):
244 assert d.vanilla() ==
"Vanilla" 245 assert d.static_func1() ==
"WithStatic1" 246 assert d.static_func2() ==
"WithStatic2" 247 assert d.static_func() == d.__class__.__name__
249 m.WithStatic1.static_value1 = 1
250 m.WithStatic2.static_value2 = 2
251 assert d.static_value1 == 1
252 assert d.static_value2 == 2
253 assert d.static_value == 12
256 assert d.static_value1 == 0
258 assert d.static_value2 == 0
260 assert d.static_value == 0
265 """Mixing bases with and without dynamic attribute support""" 267 for d
in (m.VanillaDictMix1(), m.VanillaDictMix2()):
269 assert d.dynamic == 1
273 """Returning an offset (non-first MI) base class pointer should recognize the instance""" 275 n_inst = ConstructorStats.detail_reg_inst()
280 assert ConstructorStats.detail_reg_inst() == n_inst + 4
290 assert ConstructorStats.detail_reg_inst() == n_inst + 4
292 assert ConstructorStats.detail_reg_inst() == n_inst + 2
294 assert ConstructorStats.detail_reg_inst() == n_inst
298 """Tests returning an offset (non-first MI) base class pointer to a derived instance""" 300 n_inst = ConstructorStats.detail_reg_inst()
303 assert type(c1)
is m.I801C
308 assert type(d1)
is m.I801D
312 assert ConstructorStats.detail_reg_inst() == n_inst + 4
315 assert type(c2)
is m.I801C
320 assert type(d2)
is m.I801D
324 assert ConstructorStats.detail_reg_inst() == n_inst + 8
327 assert ConstructorStats.detail_reg_inst() == n_inst + 6
329 assert ConstructorStats.detail_reg_inst() == n_inst
335 assert type(e1)
is m.I801C
340 assert type(e2)
is m.I801B2
345 """Tests that diamond inheritance works as expected (issue #959)""" 354 assert d
is d.c0().
b()
355 assert d
is d.c1().
b()
356 assert d
is d.c0().
c1().
b().c0().
b()
def test_multiple_inheritance_python()
def test_mi_unaligned_base()
def test_diamond_inheritance()
void foo(CV_QUALIFIER Matrix3d &m)
def test_multiple_inheritance_virtbase()
def test_mi_base_return()
def test_multiple_inheritance_python_many_bases()
def test_multiple_inheritance_cpp()
object getattr(handle obj, handle name)
def test_multiple_inheritance_mix1()
def test_multiple_inheritance_mix2()
def test_mi_dynamic_attributes()
def test_mi_static_properties()