MCPcopy Create free account
hub / github.com/pybind/pybind11 / test_init_factory_signature

Function test_init_factory_signature

tests/test_factory_constructors.py:74–104  ·  view source on GitHub ↗
(msg)

Source from the content-addressed store, hash-verified

72
73
74def test_init_factory_signature(msg):
75 with pytest.raises(TypeError) as excinfo:
76 m.TestFactory1("invalid", "constructor", "arguments")
77 assert (
78 msg(excinfo.value)
79 == """
80 __init__(): incompatible constructor arguments. The following argument types are supported:
81 1. m.factory_constructors.TestFactory1(arg0: m.factory_constructors.tag.unique_ptr_tag, arg1: typing.SupportsInt | typing.SupportsIndex)
82 2. m.factory_constructors.TestFactory1(arg0: str)
83 3. m.factory_constructors.TestFactory1(arg0: m.factory_constructors.tag.pointer_tag)
84 4. m.factory_constructors.TestFactory1(arg0: object, arg1: typing.SupportsInt | typing.SupportsIndex, arg2: object)
85
86 Invoked with: 'invalid', 'constructor', 'arguments'
87 """
88 )
89
90 assert (
91 msg(m.TestFactory1.__init__.__doc__)
92 == """
93 __init__(*args, **kwargs)
94 Overloaded function.
95
96 1. __init__(self: m.factory_constructors.TestFactory1, arg0: m.factory_constructors.tag.unique_ptr_tag, arg1: typing.SupportsInt | typing.SupportsIndex) -> None
97
98 2. __init__(self: m.factory_constructors.TestFactory1, arg0: str) -> None
99
100 3. __init__(self: m.factory_constructors.TestFactory1, arg0: m.factory_constructors.tag.pointer_tag) -> None
101
102 4. __init__(self: m.factory_constructors.TestFactory1, arg0: object, arg1: typing.SupportsInt | typing.SupportsIndex, arg2: object) -> None
103 """
104 )
105
106
107@pytest.mark.skipif("env.GRAALPY", reason="Cannot reliably trigger GC")

Callers

nothing calls this directly

Calls 2

msgFunction · 0.85
TestFactory1Method · 0.80

Tested by

no test coverage detected