mirror of
https://github.com/pybind/pybind11.git
synced 2026-05-05 06:01:36 +00:00
Changing all but one std::runtime_error to std::invalid_argument, which appears as ValueError in the Python interpreter. Adding test_cannot_disown_use_count_ne_1. (#2883)
This commit is contained in:
committed by
GitHub
parent
3a336a2047
commit
6a7e9f42fe
@@ -85,6 +85,26 @@ def test_pass_unique_ptr_disowns(pass_f, rtrn_f, expected):
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"pass_f, rtrn_f",
|
||||
[
|
||||
(m.pass_uqmp, m.rtrn_uqmp),
|
||||
(m.pass_uqcp, m.rtrn_uqcp),
|
||||
(m.pass_udmp, m.rtrn_udmp),
|
||||
(m.pass_udcp, m.rtrn_udcp),
|
||||
],
|
||||
)
|
||||
def test_cannot_disown_use_count_ne_1(pass_f, rtrn_f):
|
||||
obj = rtrn_f()
|
||||
stash = m.SharedPtrStash()
|
||||
stash.Add(obj)
|
||||
with pytest.raises(ValueError) as exc_info:
|
||||
pass_f(obj)
|
||||
assert str(exc_info.value) == (
|
||||
"Cannot disown use_count != 1 (loaded_as_unique_ptr)."
|
||||
)
|
||||
|
||||
|
||||
def test_unique_ptr_roundtrip(num_round_trips=1000):
|
||||
# Multiple roundtrips to stress-test instance registration/deregistration.
|
||||
recycled = m.atyp("passenger")
|
||||
|
||||
Reference in New Issue
Block a user