Expose protected member functions to Python using a helper class
()
| 372 | |
| 373 | |
| 374 | def 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 | |
| 395 | def test_brace_initialization(): |