You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
1.3 KiB

  1. def test_multiple_inheritance_cpp():
  2. from pybind11_tests import MIType
  3. mt = MIType(3, 4)
  4. assert mt.foo() == 3
  5. assert mt.bar() == 4
  6. def test_multiple_inheritance_mix1():
  7. from pybind11_tests import Base2
  8. class Base1:
  9. def __init__(self, i):
  10. self.i = i
  11. def foo(self):
  12. return self.i
  13. class MITypePy(Base1, Base2):
  14. def __init__(self, i, j):
  15. Base1.__init__(self, i)
  16. Base2.__init__(self, j)
  17. mt = MITypePy(3, 4)
  18. assert mt.foo() == 3
  19. assert mt.bar() == 4
  20. def test_multiple_inheritance_mix2():
  21. from pybind11_tests import Base1
  22. class Base2:
  23. def __init__(self, i):
  24. self.i = i
  25. def bar(self):
  26. return self.i
  27. class MITypePy(Base1, Base2):
  28. def __init__(self, i, j):
  29. Base1.__init__(self, i)
  30. Base2.__init__(self, j)
  31. mt = MITypePy(3, 4)
  32. assert mt.foo() == 3
  33. assert mt.bar() == 4
  34. def test_multiple_inheritance_virtbase():
  35. from pybind11_tests import Base12a, bar_base2a, bar_base2a_sharedptr
  36. class MITypePy(Base12a):
  37. def __init__(self, i, j):
  38. Base12a.__init__(self, i, j)
  39. mt = MITypePy(3, 4)
  40. assert mt.bar() == 4
  41. assert bar_base2a(mt) == 4
  42. assert bar_base2a_sharedptr(mt) == 4