pybind11/tests/test_python_multiple_inheritance.py

47 lines
1.0 KiB
Python
Raw Normal View History

# Adapted from:
# https://github.com/google/clif/blob/5718e4d0807fd3b6a8187dde140069120b81ecef/clif/testing/python/python_multiple_inheritance_test.py
from pybind11_tests import python_multiple_inheritance as m
class PC(m.CppBase):
pass
class PPCC(PC, m.CppDrvd):
pass
2023-07-31 23:16:46 +00:00
class PPCC2(PC, m.CppDrv2):
pass
2023-07-28 04:28:14 +00:00
def test_PC():
d = PC(11)
assert d.get_base_value() == 11
d.reset_base_value(13)
assert d.get_base_value() == 13
def test_PPCC():
d = PPCC(11)
assert d.get_drvd_value() == 33
d.reset_drvd_value(55)
assert d.get_drvd_value() == 55
assert d.get_base_value() == 11
assert d.get_base_value_from_drvd() == 11
d.reset_base_value(20)
assert d.get_base_value() == 20
assert d.get_base_value_from_drvd() == 20
d.reset_base_value_from_drvd(30)
assert d.get_base_value() == 30
assert d.get_base_value_from_drvd() == 30
2023-07-31 23:16:46 +00:00
def test_PPCC2():
d = PPCC2(13)
assert d.get_drv2_value() == 65
assert d.get_drvd_value() == 39
assert d.get_base_value() == 13