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

Function test_inheritance_init

tests/test_class.py:232–251  ·  view source on GitHub ↗
(msg)

Source from the content-addressed store, hash-verified

230
231
232def test_inheritance_init(msg):
233 # Single base
234 class Python(m.Pet):
235 def __init__(self):
236 pass
237
238 with pytest.raises(TypeError) as exc_info:
239 Python()
240 expected = "m.class_.Pet.__init__() must be called when overriding __init__"
241 assert msg(exc_info.value) == expected
242
243 # Multiple bases
244 class RabbitHamster(m.Rabbit, m.Hamster):
245 def __init__(self):
246 m.Rabbit.__init__(self, "RabbitHamster")
247
248 with pytest.raises(TypeError) as exc_info:
249 RabbitHamster()
250 expected = "m.class_.Hamster.__init__() must be called when overriding __init__"
251 assert msg(exc_info.value) == expected
252
253
254@pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 3

PythonClass · 0.85
msgFunction · 0.85
RabbitHamsterClass · 0.85

Tested by

no test coverage detected