4 from pybind11_tests
import ConstructorStats
5 from pybind11_tests
import multiple_inheritance
as m
15 @pytest.mark.xfail(
"env.PYPY")
24 class MITypePy(Base1, m.Base2):
26 Base1.__init__(self, i)
27 m.Base2.__init__(self, j)
43 class MITypePy(m.Base1, Base2):
45 m.Base1.__init__(self, i)
46 Base2.__init__(self, j)
54 @pytest.mark.xfail(
"env.PYPY")
56 class MI1(m.Base1, m.Base2):
58 m.Base1.__init__(self, i)
59 m.Base2.__init__(self, j)
65 class MI2(B1, m.Base1, m.Base2):
68 m.Base1.__init__(self, i)
69 m.Base2.__init__(self, j)
73 MI2.__init__(self, i, j)
75 class MI4(MI3, m.Base2):
77 MI3.__init__(self, i, j)
79 m.Base2.__init__(self, i + 100)
81 class MI5(m.Base2, B1, m.Base1):
84 m.Base1.__init__(self, i)
85 m.Base2.__init__(self, j)
87 class MI6(m.Base2, B1):
89 m.Base2.__init__(self, i)
107 MI6.__init__(self, i)
111 MI6.__init__(self, i)
117 MI6.__init__(self, i)
120 assert mi1.foo() == 1
121 assert mi1.bar() == 2
125 assert mi2.foo() == 3
126 assert mi2.bar() == 4
130 assert mi3.foo() == 5
131 assert mi3.bar() == 6
135 assert mi4.foo() == 7
136 assert mi4.bar() == 8
140 assert mi5.foo() == 10
141 assert mi5.bar() == 11
145 assert mi6.bar() == 12
149 assert mi7.bar() == 13
153 assert mi8.bar() == 14
157 assert mi8b.bar() == 15
161 class MIMany14(m.BaseN1, m.BaseN2, m.BaseN3, m.BaseN4):
163 m.BaseN1.__init__(self, 1)
164 m.BaseN2.__init__(self, 2)
165 m.BaseN3.__init__(self, 3)
166 m.BaseN4.__init__(self, 4)
168 class MIMany58(m.BaseN5, m.BaseN6, m.BaseN7, m.BaseN8):
170 m.BaseN5.__init__(self, 5)
171 m.BaseN6.__init__(self, 6)
172 m.BaseN7.__init__(self, 7)
173 m.BaseN8.__init__(self, 8)
186 m.BaseN9.__init__(self, 9)
187 m.BaseN10.__init__(self, 10)
188 m.BaseN11.__init__(self, 11)
189 m.BaseN12.__init__(self, 12)
190 m.BaseN13.__init__(self, 13)
191 m.BaseN14.__init__(self, 14)
192 m.BaseN15.__init__(self, 15)
193 m.BaseN16.__init__(self, 16)
195 class MIMany19(MIMany14, MIMany58, m.BaseN9):
197 MIMany14.__init__(self)
198 MIMany58.__init__(self)
199 m.BaseN9.__init__(self, 9)
201 class MIMany117(MIMany14, MIMany58, MIMany916, m.BaseN17):
203 MIMany14.__init__(self)
204 MIMany58.__init__(self)
205 MIMany916.__init__(self)
206 m.BaseN17.__init__(self, 17)
210 for i
in range(1, 4):
215 for i
in range(9, 16):
220 for i
in range(1, 9):
225 for i
in range(1, 17):
230 class MITypePy(m.Base12a):
232 m.Base12a.__init__(self, i, j)
236 assert m.bar_base2a(mt) == 4
237 assert m.bar_base2a_sharedptr(mt) == 4
241 """Mixing bases with and without static properties should be possible 242 and the result should be independent of base definition order""" 244 for d
in (m.VanillaStaticMix1(), m.VanillaStaticMix2()):
245 assert d.vanilla() ==
"Vanilla" 246 assert d.static_func1() ==
"WithStatic1" 247 assert d.static_func2() ==
"WithStatic2" 248 assert d.static_func() == d.__class__.__name__
250 m.WithStatic1.static_value1 = 1
251 m.WithStatic2.static_value2 = 2
252 assert d.static_value1 == 1
253 assert d.static_value2 == 2
254 assert d.static_value == 12
257 assert d.static_value1 == 0
259 assert d.static_value2 == 0
261 assert d.static_value == 0
266 """Mixing bases with and without dynamic attribute support""" 268 for d
in (m.VanillaDictMix1(), m.VanillaDictMix2()):
270 assert d.dynamic == 1
274 """Returning an offset (non-first MI) base class pointer should recognize the instance""" 276 n_inst = ConstructorStats.detail_reg_inst()
281 assert ConstructorStats.detail_reg_inst() == n_inst + 4
291 assert ConstructorStats.detail_reg_inst() == n_inst + 4
293 assert ConstructorStats.detail_reg_inst() == n_inst + 2
295 assert ConstructorStats.detail_reg_inst() == n_inst
299 """Tests returning an offset (non-first MI) base class pointer to a derived instance""" 301 n_inst = ConstructorStats.detail_reg_inst()
304 assert type(c1)
is m.I801C
309 assert type(d1)
is m.I801D
313 assert ConstructorStats.detail_reg_inst() == n_inst + 4
316 assert type(c2)
is m.I801C
321 assert type(d2)
is m.I801D
325 assert ConstructorStats.detail_reg_inst() == n_inst + 8
328 assert ConstructorStats.detail_reg_inst() == n_inst + 6
330 assert ConstructorStats.detail_reg_inst() == n_inst
336 assert type(e1)
is m.I801C
341 assert type(e2)
is m.I801B2
346 """Tests that diamond inheritance works as expected (issue #959)""" 355 assert d
is d.c0().
b()
356 assert d
is d.c1().
b()
357 assert d
is d.c0().c1().
b().c0().
b()
364 assert o.get_b_b() == 1
372 assert o.get_b_b() == 1
373 assert o.get_c_b() == 1
375 assert o.get_c_c() == 2
384 assert o.get_b_b() == 1
385 assert o.get_c_b() == 1
386 assert o.get_d0_b() == 1
388 assert o.get_c_c() == 2
389 assert o.get_d0_c() == 2
391 assert o.get_d0_d0() == 3
400 assert o.get_b_b() == 1
401 assert o.get_c_b() == 1
402 assert o.get_d1_b() == 1
404 assert o.get_c_c() == 2
405 assert o.get_d1_c() == 2
407 assert o.get_d1_d1() == 4
418 assert o.get_b_b() == 1
419 assert o.get_c_b() == 1
420 assert o.get_d0_b() == 1
421 assert o.get_d1_b() == 1
422 assert o.get_e_b() == 1
424 assert o.get_c_c() == 2
425 assert o.get_d0_c() == 2
426 assert o.get_d1_c() == 2
427 assert o.get_e_c() == 2
429 assert o.get_d0_d0() == 3
430 assert o.get_e_d0() == 3
432 assert o.get_d1_d1() == 4
433 assert o.get_e_d1() == 4
435 assert o.get_e_e() == 5
447 assert o.get_b_b() == 1
448 assert o.get_c_b() == 1
449 assert o.get_d0_b() == 1
450 assert o.get_d1_b() == 1
451 assert o.get_e_b() == 1
452 assert o.get_f_b() == 1
454 assert o.get_c_c() == 2
455 assert o.get_d0_c() == 2
456 assert o.get_d1_c() == 2
457 assert o.get_e_c() == 2
458 assert o.get_f_c() == 2
460 assert o.get_d0_d0() == 3
461 assert o.get_e_d0() == 3
462 assert o.get_f_d0() == 3
464 assert o.get_d1_d1() == 4
465 assert o.get_e_d1() == 4
466 assert o.get_f_d1() == 4
468 assert o.get_e_e() == 5
469 assert o.get_f_e() == 5
471 assert o.get_f_f() == 6
475 """Tests extending a Python class from a single inheritor of a MI class""" 493 assert o.get_g_g() == 7
def test_python_inherit_from_mi()
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()
Array< int, Dynamic, 1 > v
def test_pr3635_diamond_f()
def test_mi_base_return()
def test_pr3635_diamond_c()
def test_multiple_inheritance_python_many_bases()
def test_multiple_inheritance_cpp()
def test_pr3635_diamond_b()
object getattr(handle obj, handle name)
Double_ range(const Point2_ &p, const Point2_ &q)
def test_pr3635_diamond_d1()
def test_pr3635_diamond_e()
def test_multiple_inheritance_mix1()
def test_multiple_inheritance_mix2()
def test_mi_dynamic_attributes()
def test_mi_static_properties()
def test_pr3635_diamond_d0()