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

Function test_bind_protected_functions

tests/test_class.py:374–392  ·  view source on GitHub ↗

Expose protected member functions to Python using a helper class

()

Source from the content-addressed store, hash-verified

372
373
374def test_bind_protected_functions():
375 """Expose protected member functions to Python using a helper class"""
376 a = m.ProtectedA()
377 assert a.foo() == 42
378
379 b = m.ProtectedB()
380 assert b.foo() == 42
381 assert m.read_foo(b.void_foo()) == 42
382 assert m.pointers_equal(b.get_self(), b)
383
384 class C(m.ProtectedB):
385 def __init__(self):
386 m.ProtectedB.__init__(self)
387
388 def foo(self):
389 return 0
390
391 c = C()
392 assert c.foo() == 0
393
394
395def test_brace_initialization():

Callers

nothing calls this directly

Calls 7

fooMethod · 0.95
fooMethod · 0.95
void_fooMethod · 0.95
get_selfMethod · 0.95
fooMethod · 0.95
ProtectedBMethod · 0.80
CClass · 0.70

Tested by

no test coverage detected