3 from pybind11_tests
import custom_type_casters
as m
11 loading ArgInspector1 argument WITH conversion allowed. Argument value = hi 15 msg(a.g(
"this is a",
"this is b"))
17 loading ArgInspector1 argument WITHOUT conversion allowed. Argument value = this is a 18 loading ArgInspector1 argument WITH conversion allowed. Argument value = this is b 20 loading ArgInspector2 argument WITH conversion allowed. Argument value = (default arg inspector 2) 24 msg(a.g(
"this is a",
"this is b", 42))
26 loading ArgInspector1 argument WITHOUT conversion allowed. Argument value = this is a 27 loading ArgInspector1 argument WITH conversion allowed. Argument value = this is b 29 loading ArgInspector2 argument WITH conversion allowed. Argument value = (default arg inspector 2) 33 msg(a.g(
"this is a",
"this is b", 42,
"this is d"))
35 loading ArgInspector1 argument WITHOUT conversion allowed. Argument value = this is a 36 loading ArgInspector1 argument WITH conversion allowed. Argument value = this is b 38 loading ArgInspector2 argument WITH conversion allowed. Argument value = this is d 43 ==
"loading ArgInspector2 argument WITHOUT conversion allowed. Argument value = arg 1" 46 msg(m.arg_inspect_func(
"A1",
"A2"))
48 loading ArgInspector2 argument WITH conversion allowed. Argument value = A1 49 loading ArgInspector1 argument WITHOUT conversion allowed. Argument value = A2 53 assert m.floats_preferred(4) == 2.0
54 assert m.floats_only(4.0) == 2.0
55 with pytest.raises(TypeError)
as excinfo:
60 floats_only(): incompatible function arguments. The following argument types are supported: 61 1. (f: float) -> float 67 assert m.ints_preferred(4) == 2
68 assert m.ints_preferred(
True) == 0
69 with pytest.raises(TypeError)
as excinfo:
74 ints_preferred(): incompatible function arguments. The following argument types are supported: 81 assert m.ints_only(4) == 2
82 with pytest.raises(TypeError)
as excinfo:
87 ints_only(): incompatible function arguments. The following argument types are supported: 96 """Tests that returning a pointer to a type that gets converted with a custom type caster gets 97 destroyed when the function has py::return_value_policy::take_ownership policy applied.""" 99 cstats = m.destruction_tester_cstats()
101 z = m.custom_caster_no_destroy()
102 assert cstats.alive() == 1
and cstats.default_constructions == 1
106 z = m.custom_caster_destroy()
108 assert cstats.default_constructions == 2
111 z = m.custom_caster_destroy_const()
113 assert cstats.default_constructions == 3
116 assert cstats.alive() == 1
120 assert m.other_lib_type(
True)
def test_custom_caster_destruction()
def test_noconvert_args(msg)
def test_custom_caster_other_lib()