mirror of
https://github.com/pybind/pybind11.git
synced 2025-02-27 08:04:56 +00:00
* git merge --squash purge_internals_versions_4_5
* Remove PYBIND11_HAS_INTERNALS_WITH_SMART_HOLDER_SUPPORT, set PYBIND11_INTERNALS_VERSION 7
* Remove all uses of PYBIND11_SMART_HOLDER_ENABLED under include/pybind11
* Remove obsolete PYBIND11_ACTUALLY_USING_SMART_HOLDER_AS_DEFAULT macro.
* Remove PYBIND11_SMART_HOLDER_ENABLED in ubench/holder_comparison.cpp
* Remove all uses of PYBIND11_SMART_HOLDER_ENABLED under tests/
* Remove `#define PYBIND11_SMART_HOLDER_ENABLED`
* Remove all uses of PYBIND11_SMART_HOLDER_TYPE_CASTERS under tests/
* Remove all uses of PYBIND11_TYPE_CASTER_BASE_HOLDER under tests/
* Add missing `#include <cstdint>`
Example error message (🐍 3.11 • ubuntu-latest • x64, GNU 13.3.0):
```
include/pybind11/detail/value_and_holder.h:56:52: error: ‘uint8_t’ is not a member of ‘std’; did you mean ‘wint_t’?
56 | inst->nonsimple.status[index] &= (std::uint8_t) ~instance::status_holder_constructed;
| ^~~~~~~
```
* Change PYBIND11_INTERNALS_VERSION to 106: It will be changed to 7 in a follow-on PR that actually changes the internals.
67 lines
1.3 KiB
Python
67 lines
1.3 KiB
Python
from __future__ import annotations
|
|
|
|
import pytest
|
|
|
|
from pybind11_tests import class_sh_virtual_py_cpp_mix as m
|
|
|
|
|
|
class PyBase(m.Base): # Avoiding name PyDerived, for more systematic naming.
|
|
def __init__(self):
|
|
m.Base.__init__(self)
|
|
|
|
def get(self):
|
|
return 323
|
|
|
|
|
|
class PyCppDerived(m.CppDerived):
|
|
def __init__(self):
|
|
m.CppDerived.__init__(self)
|
|
|
|
def get(self):
|
|
return 434
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
("ctor", "expected"),
|
|
[
|
|
(m.Base, 101),
|
|
(PyBase, 323),
|
|
(m.CppDerivedPlain, 202),
|
|
(m.CppDerived, 212),
|
|
(PyCppDerived, 434),
|
|
],
|
|
)
|
|
def test_base_get(ctor, expected):
|
|
obj = ctor()
|
|
assert obj.get() == expected
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
("ctor", "expected"),
|
|
[
|
|
(m.Base, 4101),
|
|
(PyBase, 4323),
|
|
(m.CppDerivedPlain, 4202),
|
|
(m.CppDerived, 4212),
|
|
(PyCppDerived, 4434),
|
|
],
|
|
)
|
|
def test_get_from_cpp_plainc_ptr(ctor, expected):
|
|
obj = ctor()
|
|
assert m.get_from_cpp_plainc_ptr(obj) == expected
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
("ctor", "expected"),
|
|
[
|
|
(m.Base, 5101),
|
|
(PyBase, 5323),
|
|
(m.CppDerivedPlain, 5202),
|
|
(m.CppDerived, 5212),
|
|
(PyCppDerived, 5434),
|
|
],
|
|
)
|
|
def test_get_from_cpp_unique_ptr(ctor, expected):
|
|
obj = ctor()
|
|
assert m.get_from_cpp_unique_ptr(obj) == expected
|