mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-14 09:34:46 +00:00
a8bc5f7904
``` ruff.....................................................................Failed - hook id: ruff - files were modified by this hook Fixed 44 errors: - tests/test_class_sh_basic.py: 1 × I001 (unsorted-imports) 1 × I002 (missing-required-import) - tests/test_class_sh_disowning.py: 1 × I001 (unsorted-imports) 1 × I002 (missing-required-import) - tests/test_class_sh_disowning_mi.py: 1 × I001 (unsorted-imports) 1 × I002 (missing-required-import) - tests/test_class_sh_factory_constructors.py: 1 × I001 (unsorted-imports) 1 × I002 (missing-required-import) - tests/test_class_sh_inheritance.py: 1 × I001 (unsorted-imports) 1 × I002 (missing-required-import) - tests/test_class_sh_mi_thunks.py: 1 × I001 (unsorted-imports) 1 × I002 (missing-required-import) - tests/test_class_sh_module_local.py: 1 × I001 (unsorted-imports) 1 × I002 (missing-required-import) - tests/test_class_sh_property.py: 1 × I002 (missing-required-import) - tests/test_class_sh_property_non_owning.py: 1 × I001 (unsorted-imports) 1 × I002 (missing-required-import) - tests/test_class_sh_shared_ptr_copy_move.py: 1 × I001 (unsorted-imports) 1 × I002 (missing-required-import) - tests/test_class_sh_trampoline_basic.py: 1 × I001 (unsorted-imports) 1 × I002 (missing-required-import) - tests/test_class_sh_trampoline_self_life_support.py: 1 × I001 (unsorted-imports) 1 × I002 (missing-required-import) - tests/test_class_sh_trampoline_shared_from_this.py: 1 × I001 (unsorted-imports) 1 × I002 (missing-required-import) - tests/test_class_sh_trampoline_shared_ptr_cpp_arg.py: 1 × I001 (unsorted-imports) 1 × I002 (missing-required-import) - tests/test_class_sh_trampoline_unique_ptr.py: 1 × I001 (unsorted-imports) 1 × I002 (missing-required-import) - tests/test_class_sh_unique_ptr_custom_deleter.py: 1 × I001 (unsorted-imports) 1 × I002 (missing-required-import) - tests/test_class_sh_unique_ptr_member.py: 1 × I001 (unsorted-imports) 1 × I002 (missing-required-import) - tests/test_class_sh_virtual_py_cpp_mix.py: 1 × I001 (unsorted-imports) 1 × I002 (missing-required-import) - tests/test_classh_mock.py: 1 × I001 (unsorted-imports) 1 × I002 (missing-required-import) - tests/test_descr_src_loc.py: 1 × I001 (unsorted-imports) 1 × I002 (missing-required-import) - tests/test_exc_namespace_visibility.py: 1 × I002 (missing-required-import) - tests/test_type_caster_odr_guard_1.py: 1 × I001 (unsorted-imports) 1 × I002 (missing-required-import) - tests/test_type_caster_odr_guard_2.py: 1 × I001 (unsorted-imports) 1 × I002 (missing-required-import) Found 44 errors (44 fixed, 0 remaining). ```
64 lines
1.7 KiB
Python
64 lines
1.7 KiB
Python
from __future__ import annotations
|
|
|
|
from pybind11_tests import class_sh_inheritance as m
|
|
|
|
|
|
def test_rtrn_mptr_drvd_pass_cptr_base():
|
|
d = m.rtrn_mptr_drvd()
|
|
i = m.pass_cptr_base(d) # load_impl Case 2a
|
|
assert i == 2 * 100 + 11
|
|
|
|
|
|
def test_rtrn_shmp_drvd_pass_shcp_base():
|
|
d = m.rtrn_shmp_drvd()
|
|
i = m.pass_shcp_base(d) # load_impl Case 2a
|
|
assert i == 2 * 100 + 21
|
|
|
|
|
|
def test_rtrn_mptr_drvd_up_cast_pass_cptr_drvd():
|
|
b = m.rtrn_mptr_drvd_up_cast()
|
|
# the base return is down-cast immediately.
|
|
assert b.__class__.__name__ == "drvd"
|
|
i = m.pass_cptr_drvd(b)
|
|
assert i == 2 * 100 + 12
|
|
|
|
|
|
def test_rtrn_shmp_drvd_up_cast_pass_shcp_drvd():
|
|
b = m.rtrn_shmp_drvd_up_cast()
|
|
# the base return is down-cast immediately.
|
|
assert b.__class__.__name__ == "drvd"
|
|
i = m.pass_shcp_drvd(b)
|
|
assert i == 2 * 100 + 22
|
|
|
|
|
|
def test_rtrn_mptr_drvd2_pass_cptr_bases():
|
|
d = m.rtrn_mptr_drvd2()
|
|
i1 = m.pass_cptr_base1(d) # load_impl Case 2c
|
|
assert i1 == 3 * 110 + 4 * 120 + 21
|
|
i2 = m.pass_cptr_base2(d)
|
|
assert i2 == 3 * 110 + 4 * 120 + 22
|
|
|
|
|
|
def test_rtrn_mptr_drvd2_up_casts_pass_cptr_drvd2():
|
|
b1 = m.rtrn_mptr_drvd2_up_cast1()
|
|
assert b1.__class__.__name__ == "drvd2"
|
|
i1 = m.pass_cptr_drvd2(b1)
|
|
assert i1 == 3 * 110 + 4 * 120 + 23
|
|
b2 = m.rtrn_mptr_drvd2_up_cast2()
|
|
assert b2.__class__.__name__ == "drvd2"
|
|
i2 = m.pass_cptr_drvd2(b2)
|
|
assert i2 == 3 * 110 + 4 * 120 + 23
|
|
|
|
|
|
def test_python_drvd2():
|
|
class Drvd2(m.base1, m.base2):
|
|
def __init__(self):
|
|
m.base1.__init__(self)
|
|
m.base2.__init__(self)
|
|
|
|
d = Drvd2()
|
|
i1 = m.pass_cptr_base1(d) # load_impl Case 2b
|
|
assert i1 == 110 + 21
|
|
i2 = m.pass_cptr_base2(d)
|
|
assert i2 == 120 + 22
|