@@ -158,7 +158,18 @@ def test_unique_ptr_consumer_roundtrip(pass_f, rtrn_f, moved_out, moved_in):
158158)
159159@pytest .mark .parametrize (
160160 "pass_f" ,
161- [m .consumer .pass_uq_cref , m .consumer .pass_cptr , m .consumer .pass_cref ],
161+ [
162+ # This fails with: ValueError: Cannot disown non-owning holder (loaded_as_unique_ptr).
163+ #
164+ # smart_holder_type_caster_load<T>::loaded_as_unique_ptr() attempts to pass
165+ # the not-owned cref as a new unique_ptr, which would eventually destroy the object,
166+ # and is thus (correctly) suppressed.
167+ # To fix this, smart_holder would need to store the (original) unique_ptr reference,
168+ # e.g. using a union of unique_ptr + shared_ptr.
169+ pytest .param (m .consumer .pass_uq_cref , marks = pytest .mark .xfail ),
170+ m .consumer .pass_cptr ,
171+ m .consumer .pass_cref ,
172+ ],
162173)
163174def test_unique_ptr_cref_consumer_roundtrip (rtrn_f , pass_f ):
164175 c = m .consumer ()
@@ -168,16 +179,6 @@ def test_unique_ptr_cref_consumer_roundtrip(rtrn_f, pass_f):
168179
169180 c .pass_uq_valu (passenger ) # moves passenger to C++ (checked above)
170181
171- if pass_f == m .consumer .pass_uq_cref :
172- # This fails with: ValueError: Cannot disown non-owning holder (loaded_as_unique_ptr).
173- #
174- # smart_holder_type_caster_load<T>::loaded_as_unique_ptr() attempts to pass
175- # the not-owned cref as a new unique_ptr, which would eventually destroy the object,
176- # and is thus (correctly) suppressed.
177- # To fix this, smart_holder would need to store the (original) unique_ptr reference,
178- # e.g. using a union of unique_ptr + shared_ptr.
179- pytest .xfail ()
180-
181182 for _ in range (10 ):
182183 cref = rtrn_f (c ) # fetches const reference, should keep-alive parent c
183184 assert pass_f (c , cref ) == mtxt_orig
0 commit comments