def test_return_none(capture): from pybind11_tests import Parent with capture: p = Parent() assert capture == "Allocating parent." with capture: p.returnNullChildKeepAliveChild() pytest.gc_collect() assert capture == "" with capture: del p pytest.gc_collect() assert capture == "Releasing parent." with capture: p = Parent() assert capture == "Allocating parent." with capture: p.returnNullChildKeepAliveParent() pytest.gc_collect() assert capture == "" with capture: del p pytest.gc_collect() assert capture == "Releasing parent."
def test_return_none(capture): from pybind11_tests import Parent, ConstructorStats n_inst = ConstructorStats.detail_reg_inst() with capture: p = Parent() assert capture == "Allocating parent." with capture: p.returnNullChildKeepAliveChild() assert ConstructorStats.detail_reg_inst() == n_inst + 1 assert capture == "" with capture: del p assert ConstructorStats.detail_reg_inst() == n_inst assert capture == "Releasing parent." with capture: p = Parent() assert capture == "Allocating parent." with capture: p.returnNullChildKeepAliveParent() assert ConstructorStats.detail_reg_inst() == n_inst + 1 assert capture == "" with capture: del p assert ConstructorStats.detail_reg_inst() == n_inst assert capture == "Releasing parent."
def test_return_none(capture): from pybind11_tests import Parent with capture: p = Parent() if capture != "Allocating parent.": raise AssertionError with capture: p.returnNullChildKeepAliveChild() pytest.gc_collect() if capture != "": raise AssertionError with capture: del p pytest.gc_collect() if capture != "Releasing parent.": raise AssertionError with capture: p = Parent() if capture != "Allocating parent.": raise AssertionError with capture: p.returnNullChildKeepAliveParent() pytest.gc_collect() if capture != "": raise AssertionError with capture: del p pytest.gc_collect() if capture != "Releasing parent.": raise AssertionError