MCPcopy Create free account
hub / github.com/pybind/pybind11 / test_ptr

Function test_ptr

tests/test_class_sh_property.py:71–84  ·  view source on GitHub ↗
(field_type, num_default, outer_type, m_attr, r_kind)

Source from the content-addressed store, hash-verified

69@pytest.mark.parametrize("m_attr", ["m_mptr", "m_cptr"])
70@pytest.mark.parametrize("r_kind", ["_readonly", "_readwrite"])
71def test_ptr(field_type, num_default, outer_type, m_attr, r_kind):
72 m_attr_r_kind = m_attr + r_kind
73 outer = outer_type()
74 assert getattr(outer, m_attr_r_kind) is None
75 field = field_type()
76 assert field.num == num_default
77 setattr(outer, m_attr + "_readwrite", field)
78 assert getattr(outer, m_attr_r_kind).num == num_default
79 field.num = 76
80 assert getattr(outer, m_attr_r_kind).num == 76
81 # Change to -88 or -99 to demonstrate Undefined Behavior (dangling pointer).
82 if num_default == 88 and m_attr == "m_mptr":
83 del field
84 assert getattr(outer, m_attr_r_kind).num == 76
85
86
87@pytest.mark.parametrize("m_attr_readwrite", ["m_uqmp_readwrite", "m_uqcp_readwrite"])

Callers

nothing calls this directly

Calls 2

getattrFunction · 0.85
setattrFunction · 0.85

Tested by

no test coverage detected