Skip to content

Commit eb1787c

Browse files
committed
Add back test_potentially_slicing_shared_ptr_not_convertible_error(), it got lost accidentally in commit 56d23dc
1 parent ff0792e commit eb1787c

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

tests/test_potentially_slicing_shared_ptr.py

+15
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,18 @@ def test_with_wp_owner(holder_kind, set_meth, expected_code):
112112
gc.collect()
113113
if GC_IS_RELIABLE:
114114
assert wpo.get_code() == -999
115+
116+
117+
def test_potentially_slicing_shared_ptr_not_convertible_error():
118+
with pytest.raises(Exception) as excinfo:
119+
m.SH_rtrn_potentially_slicing_shared_ptr("")
120+
assert str(excinfo.value) == (
121+
'"str" object is not convertible to std::shared_ptr<T>'
122+
" (with T = pybind11_tests::potentially_slicing_shared_ptr::VirtBase<0>)"
123+
)
124+
with pytest.raises(Exception) as excinfo:
125+
m.SP_rtrn_potentially_slicing_shared_ptr([])
126+
assert str(excinfo.value) == (
127+
'"list" object is not convertible to std::shared_ptr<T>'
128+
" (with T = pybind11_tests::potentially_slicing_shared_ptr::VirtBase<1>)"
129+
)

0 commit comments

Comments
 (0)