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

Function test_valu_getter

tests/test_class_sh_property.py:16–28  ·  view source on GitHub ↗
(m_attr)

Source from the content-addressed store, hash-verified

14)
15@pytest.mark.parametrize("m_attr", ["m_valu_readonly", "m_valu_readwrite"])
16def test_valu_getter(m_attr):
17 # Reduced from PyCLIF test:
18 # https://github.com/google/clif/blob/c371a6d4b28d25d53a16e6d2a6d97305fb1be25a/clif/testing/python/nested_fields_test.py#L56
19 outer = m.Outer()
20 field = getattr(outer, m_attr)
21 assert field.num == -99
22 with pytest.raises(ValueError) as excinfo:
23 m.DisownOuter(outer)
24 assert str(excinfo.value) == "Cannot disown use_count != 1 (load_as_unique_ptr)."
25 del field
26 m.DisownOuter(outer)
27 with pytest.raises(ValueError, match="Python instance was disowned") as excinfo:
28 getattr(outer, m_attr)
29
30
31def test_valu_setter():

Callers

nothing calls this directly

Calls 3

getattrFunction · 0.85
strClass · 0.85
OuterMethod · 0.80

Tested by

no test coverage detected