mirror of
https://github.com/pybind/pybind11.git
synced 2026-05-04 13:41:36 +00:00
```
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).
```
39 lines
872 B
Python
39 lines
872 B
Python
from __future__ import annotations
|
|
|
|
import pytest
|
|
|
|
import pybind11_tests.class_sh_trampoline_self_life_support as m
|
|
|
|
|
|
class PyBig5(m.Big5):
|
|
pass
|
|
|
|
|
|
def test_m_big5():
|
|
obj = m.Big5("Seed")
|
|
assert obj.history == "Seed"
|
|
o1, o2 = m.action(obj, 0)
|
|
assert o1 is not obj
|
|
assert o1.history == "Seed"
|
|
with pytest.raises(ValueError) as excinfo:
|
|
_ = obj.history
|
|
assert "Python instance was disowned" in str(excinfo.value)
|
|
assert o2 is None
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
("action_id", "expected_history"),
|
|
[
|
|
(0, "Seed_CpCtor"),
|
|
(1, "Seed_MvCtor"),
|
|
(2, "Seed_OpEqLv"),
|
|
(3, "Seed_OpEqRv"),
|
|
],
|
|
)
|
|
def test_py_big5(action_id, expected_history):
|
|
obj = PyBig5("Seed")
|
|
assert obj.history == "Seed"
|
|
o1, o2 = m.action(obj, action_id)
|
|
assert o1 is obj
|
|
assert o2.history == expected_history
|