| 14 | ) |
| 15 | @pytest.mark.parametrize("m_attr", ["m_valu_readonly", "m_valu_readwrite"]) |
| 16 | def 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 | |
| 31 | def test_valu_setter(): |