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

Function test_dispatch_issue

tests/test_virtual_functions.py:245–264  ·  view source on GitHub ↗

#159: virtual function dispatch has problems with similar-named functions

(msg)

Source from the content-addressed store, hash-verified

243
244
245def test_dispatch_issue(msg):
246 """#159: virtual function dispatch has problems with similar-named functions"""
247
248 class PyClass1(m.DispatchIssue):
249 def dispatch(self):
250 return "Yay.."
251
252 class PyClass2(m.DispatchIssue):
253 def dispatch(self):
254 with pytest.raises(RuntimeError) as excinfo:
255 super().dispatch()
256 assert (
257 msg(excinfo.value)
258 == 'Tried to call pure virtual function "Base::dispatch"'
259 )
260
261 return m.dispatch_issue_go(PyClass1())
262
263 b = PyClass2()
264 assert m.dispatch_issue_go(b) == "Yay.."
265
266
267def test_recursive_dispatch_issue():

Callers

nothing calls this directly

Calls 1

PyClass2Class · 0.85

Tested by

no test coverage detected