===================================================================================== FAILURES ======================================================================================
__________________________________________________________________________________ test_smart_ptr ___________________________________________________________________________________
capture = <conftest.Capture object at 0x138aa3828210>
@pytest.mark.skipif("env.GRAALPY", reason="Cannot reliably trigger GC")
def test_smart_ptr(capture):
# Object1
for i, o in enumerate(
[m.make_object_1(), m.make_object_2(), m.MyObject1(3)], start=1
):
assert o.getRefCount() == 1
with capture:
m.print_object_1(o)
m.print_object_2(o)
m.print_object_3(o)
m.print_object_4(o)
assert capture == f"MyObject1[{i}]\n" * 4
for i, o in enumerate(
[m.make_myobject1_1(), m.make_myobject1_2(), m.MyObject1(6), 7], start=4
):
print(o)
with capture:
if not isinstance(o, int):
m.print_object_1(o)
m.print_object_2(o)
m.print_object_3(o)
m.print_object_4(o)
m.print_myobject1_1(o)
m.print_myobject1_2(o)
m.print_myobject1_3(o)
m.print_myobject1_4(o)
times = 4 if isinstance(o, int) else 8
assert capture == f"MyObject1[{i}]\n" * times
cstats = ConstructorStats.get(m.MyObject1)
assert cstats.alive() == 0
expected_values = [f"MyObject1[{i}]" for i in range(1, 7)] + ["MyObject1[7]"] * 4
> assert cstats.values() == expected_values
E AssertionError: assert ['MyObject1[0...ect1[5]', ...] == ['MyObject1[1...ect1[6]', ...]
E
E At index 0 diff: 'MyObject1[0]' != 'MyObject1[1]'
E Left contains one more item: 'MyObject1[7]'
E Use -v to get more diff
capture = <conftest.Capture object at 0x138aa3828210>
cstats = <pybind11_tests.ConstructorStats object at 0x138aa35336f0>
expected_values = ['MyObject1[1]', 'MyObject1[2]', 'MyObject1[3]', 'MyObject1[4]', 'MyObject1[5]', 'MyObject1[6]', ...]
i = 7
o = 7
times = 4
../../pybind11-3.0.3/tests/test_smart_ptr.py:46: AssertionError
------------------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------------------
### (anonymous namespace)::MyObject1 @ 0x13899bbf97f0 destroyed
### Object @ 0x13899bbf97f0 destroyed
### ref<(anonymous namespace)::MyObject1> @ 0x138aa3594fc8 destroyed
### (anonymous namespace)::MyObject1 @ 0x13899bbf97d0 destroyed
### Object @ 0x13899bbf97d0 destroyed
### ref<(anonymous namespace)::MyObject1> @ 0x138aa20a5588 destroyed
### (anonymous namespace)::MyObject1 @ 0x13899bbf97e0 destroyed
### Object @ 0x13899bbf97e0 destroyed
### ref<(anonymous namespace)::MyObject1> @ 0x138aa332d808 destroyed
_________________________________________________________________________________ test_cpp_casting __________________________________________________________________________________
def test_cpp_casting():
assert m.cpp_copy(m.fixed_r()) == 22.0
assert m.cpp_copy(m.fixed_c()) == 22.0
z = np.array([[5.0, 6], [7, 8]])
assert m.cpp_copy(z) == 7.0
> assert m.cpp_copy(m.get_cm_ref()) == 21.0
E assert 31.0 == 21.0
E + where 31.0 = <built-in method cpp_copy of py===================================================================================== FAILURES ======================================================================================
__________________________________________________________________________________ test_smart_ptr ___________________________________________________________________________________
capture = <conftest.Capture object at 0x138aa3828210>
@pytest.mark.skipif("env.GRAALPY", reason="Cannot reliably trigger GC")
def test_smart_ptr(capture):
# Object1
for i, o in enumerate(
[m.make_object_1(), m.make_object_2(), m.MyObject1(3)], start=1
):
assert o.getRefCount() == 1
with capture:
m.print_object_1(o)
m.print_object_2(o)
m.print_object_3(o)
m.print_object_4(o)
assert capture == f"MyObject1[{i}]\n" * 4
for i, o in enumerate(
[m.make_myobject1_1(), m.make_myobject1_2(), m.MyObject1(6), 7], start=4
):
print(o)
with capture:
if not isinstance(o, int):
m.print_object_1(o)
m.print_object_2(o)
m.print_object_3(o)
m.print_object_4(o)
m.print_myobject1_1(o)
m.print_myobject1_2(o)
m.print_myobject1_3(o)
m.print_myobject1_4(o)
times = 4 if isinstance(o, int) else 8
assert capture == f"MyObject1[{i}]\n" * times
cstats = ConstructorStats.get(m.MyObject1)
assert cstats.alive() == 0
expected_values = [f"MyObject1[{i}]" for i in range(1, 7)] + ["MyObject1[7]"] * 4
> assert cstats.values() == expected_values
E AssertionError: assert ['MyObject1[0...ect1[5]', ...] == ['MyObject1[1...ect1[6]', ...]
E
E At index 0 diff: 'MyObject1[0]' != 'MyObject1[1]'
E Left contains one more item: 'MyObject1[7]'
E Use -v to get more diff
capture = <conftest.Capture object at 0x138aa3828210>
cstats = <pybind11_tests.ConstructorStats object at 0x138aa35336f0>
expected_values = ['MyObject1[1]', 'MyObject1[2]', 'MyObject1[3]', 'MyObject1[4]', 'MyObject1[5]', 'MyObject1[6]', ...]
i = 7
o = 7
times = 4
../../pybind11-3.0.3/tests/test_smart_ptr.py:46: AssertionError
------------------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------------------
### (anonymous namespace)::MyObject1 @ 0x13899bbf97f0 destroyed
### Object @ 0x13899bbf97f0 destroyed
### ref<(anonymous namespace)::MyObject1> @ 0x138aa3594fc8 destroyed
### (anonymous namespace)::MyObject1 @ 0x13899bbf97d0 destroyed
### Object @ 0x13899bbf97d0 destroyed
### ref<(anonymous namespace)::MyObject1> @ 0x138aa20a5588 destroyed
### (anonymous namespace)::MyObject1 @ 0x13899bbf97e0 destroyed
### Object @ 0x13899bbf97e0 destroyed
### ref<(anonymous namespace)::MyObject1> @ 0x138aa332d808 destroyed
_________________________________________________________________________________ test_cpp_casting __________________________________________________________________________________
def test_cpp_casting():
assert m.cpp_copy(m.fixed_r()) == 22.0
assert m.cpp_copy(m.fixed_c()) == 22.0
z = np.array([[5.0, 6], [7, 8]])
assert m.cpp_copy(z) == 7.0
> assert m.cpp_copy(m.get_cm_ref()) == 21.0
E assert 31.0 == 21.0
E + where 31.0 = <built-in method cpp_copy of pybind11_builtins.pybind11_detail_function_record_v1_system_libcpp_abi1 object at 0x138aa0c64490>(array([[ 0., 22., 20.],\n [31., 37., 33.],\n [41., 42., 38.]]))
E + where <built-in method cpp_copy of pybind11_builtins.pybind11_detail_function_record_v1_system_libcpp_abi1 object at 0x138aa0c64490> = m.cpp_copy
E + and array([[ 0., 22., 20.],\n [31., 37., 33.],\n [41., 42., 38.]]) = <built-in method get_cm_ref of pybind11_builtins.pybind11_detail_function_record_v1_system_libcpp_abi1 object at 0x138aa0c3fdd0>()
E + where <built-in method get_cm_ref of pybind11_builtins.pybind11_detail_function_record_v1_system_libcpp_abi1 object at 0x138aa0c3fdd0> = m.get_cm_ref
z = array([[5., 6.],
[7., 8.]])
../../pybind11-3.0.3/tests/test_eigen_matrix.py:125: AssertionError
___________________________________________________________________________________ test_sequence ___________________________________________________________________________________
def test_sequence():
cstats = ConstructorStats.get(m.Sequence)
s = m.Sequence(5)
if not env.GRAALPY:
> assert cstats.values() == ["of size", "5"]
E AssertionError: assert ['of size', '...of size', '5'] == ['of size', '5']
E
E Left contains 2 more items, first extra item: 'of size'
E Use -v to get more diff
cstats = <pybind11_tests.ConstructorStats object at 0x138aa3885db0>
s = <pybind11_tests.sequences_and_iterators.Sequence object at 0x138aa3885c70>
../../pybind11-3.0.3/tests/test_sequences_and_iterators.py:125: AssertionError
------------------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------------------
### test_submodule_sequences_and_iterators(module_&)::Sequence @ 0x13899bbf9e00 created of size 5
____________________________________________________________________________ test_methods_and_attributes ____________________________________________________________________________
def test_methods_and_attributes():
instance1 = m.ExampleMandA()
instance2 = m.ExampleMandA(32)
instance1.add1(instance2)
instance1.add2(instance2)
instance1.add3(instance2)
instance1.add4(instance2)
instance1.add5(instance2)
instance1.add6(32)
instance1.add7(32)
instance1.add8(32)
instance1.add9(32)
instance1.add10(32)
assert str(instance1) == "ExampleMandA[value=320]"
assert str(instance2) == "ExampleMandA[value=32]"
assert str(instance1.self1()) == "ExampleMandA[value=320]"
assert str(instance1.self2()) == "ExampleMandA[value=320]"
assert str(instance1.self3()) == "ExampleMandA[value=320]"
assert str(instance1.self4()) == "ExampleMandA[value=320]"
assert str(instance1.self5()) == "ExampleMandA[value=320]"
assert instance1.internal1() == 320
assert instance1.internal2() == 320
assert instance1.internal3() == 320
assert instance1.internal4() == 320
assert instance1.internal5() == 320
assert instance1.overloaded() == "()"
assert instance1.overloaded(0) == "(int)"
assert instance1.overloaded(1, 1.0) == "(int, float)"
assert instance1.overloaded(2.0, 2) == "(float, int)"
assert instance1.overloaded(3, 3) == "(int, int)"
assert instance1.overloaded(4.0, 4.0) == "(float, float)"
assert instance1.overloaded_const(-3) == "(int) const"
assert instance1.overloaded_const(5, 5.0) == "(int, float) const"
assert instance1.overloaded_const(6.0, 6) == "(float, int) const"
assert instance1.overloaded_const(7, 7) == "(int, int) const"
assert instance1.overloaded_const(8.0, 8.0) == "(float, float) const"
assert instance1.overloaded_float(1, 1) == "(float, float)"
assert instance1.overloaded_float(1, 1.0) == "(float, float)"
assert instance1.overloaded_float(1.0, 1) == "(float, float)"
assert instance1.overloaded_float(1.0, 1.0) == "(float, float)"
assert instance1.value == 320
in===================================================================================== FAILURES ======================================================================================
__________________________________________________________________________________ test_smart_ptr ___________________________________________________________________________________
capture = <conftest.Capture object at 0x138aa3828210>
@pytest.mark.skipif("env.GRAALPY", reason="Cannot reliably trigger GC")
def test_smart_ptr(capture):
# Object1
for i, o in enumerate(
[m.make_object_1(), m.make_object_2(), m.MyObject1(3)], start=1
):
assert o.getRefCount() == 1
with capture:
m.print_object_1(o)
m.print_object_2(o)
m.print_object_3(o)
m.print_object_4(o)
assert capture == f"MyObject1[{i}]\n" * 4
for i, o in enumerate(
[m.make_myobject1_1(), m.make_myobject1_2(), m.MyObject1(6), 7], start=4
):
print(o)
with capture:
if not isinstance(o, int):
m.print_object_1(o)
m.print_object_2(o)
m.print_object_3(o)
m.print_object_4(o)
m.print_myobject1_1(o)
m.print_myobject1_2(o)
m.print_myobject1_3(o)
m.print_myobject1_4(o)
times = 4 if isinstance(o, int) else 8
assert capture == f"MyObject1[{i}]\n" * times
cstats = ConstructorStats.get(m.MyObject1)
assert cstats.alive() == 0
expected_values = [f"MyObject1[{i}]" for i in range(1, 7)] + ["MyObject1[7]"] * 4
> assert cstats.values() == expected_values
E AssertionError: assert ['MyObject1[0...ect1[5]', ...] == ['MyObject1[1...ect1[6]', ...]
E
E At index 0 diff: 'MyObject1[0]' != 'MyObject1[1]'
E Left contains one more item: 'MyObject1[7]'
E Use -v to get more diff
capture = <conftest.Capture object at 0x138aa3828210>
cstats = <pybind11_tests.ConstructorStats object at 0x138aa35336f0>
expected_values = ['MyObject1[1]', 'MyObject1[2]', 'MyObject1[3]', 'MyObject1[4]', 'MyObject1[5]', 'MyObject1[6]', ...]
i = 7
o = 7
times = 4
../../pybind11-3.0.3/tests/test_smart_ptr.py:46: AssertionError
------------------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------------------
### (anonymous namespace)::MyObject1 @ 0x13899bbf97f0 destroyed
### Object @ 0x13899bbf97f0 destroyed
### ref<(anonymous namespace)::MyObject1> @ 0x138aa3594fc8 destroyed
### (anonymous namespace)::MyObject1 @ 0x13899bbf97d0 destroyed
### Object @ 0x13899bbf97d0 destroyed
### ref<(anonymous namespace)::MyObject1> @ 0x138aa20a5588 destroyed
### (anonymous namespace)::MyObject1 @ 0x13899bbf97e0 destroyed
### Object @ 0x13899bbf97e0 destroyed
### ref<(anonymous namespace)::MyObject1> @ 0x138aa332d808 destroyed
_________________________________________________________________________________ test_cpp_casting __________________________________________________________________________________
def test_cpp_casting():
assert m.cpp_copy(m.fixed_r()) == 22.0
assert m.cpp_copy(m.fixed_c()) == 22.0
z = np.array([[5.0, 6], [7, 8]])
assert m.cpp_copy(z) == 7.0
> assert m.cpp_copy(m.get_cm_ref()) == 21.0
E assert 31.0 == 21.0
E + where 31.0 = <built-in method cpp_copy of pybind11_builtins.pybind11_detail_function_record_v1_system_libcpp_abi1 object at 0x138aa0c64490>(array([[ 0., 22., 20.],\n [31., 37., 33.],\n [41., 42., 38.]]))
E + where <built-in method cpp_copy of pybind11_builtins.pybind11_detail_function_record_v1_system_libcpp_abi1 object at 0x138aa0c64490> = m.cpp_copy
E + and array([[ 0., 22., 20.],\n [31., 37., 33.],\n [41., 42., 38.]]) = <built-in method get_cm_ref of pybind11_builtins.pybind11_detail_function_record_v1_system_libcpp_abi1 object at 0x138aa0c3fdd0>()
E + where <built-in method get_cm_ref of pybind11_builtins.pybind11_detail_function_record_v1_system_libcpp_abi1 object at 0x138aa0c3fdd0> = m.get_cm_ref
z = array([[5., 6.],
[7., 8.]])
../../pybind11-3.0.3/tests/test_eigen_matrix.py:125: AssertionError
___________________________________________________________________________________ test_sequence ___________________________________________________________________________________
def test_sequence():
cstats = ConstructorStats.get(m.Sequence)
s = m.Sequence(5)
if not env.GRAALPY:
> assert cstats.values() == ["of size", "5"]
E AssertionError: assert ['of size', '...of size', '5'] == ['of size', '5']
E
E Left contains 2 more items, first extra item: 'of size'
E Use -v to get more diff
cstats = <pybind11_tests.ConstructorStats object at 0x138aa3885db0>
s = <pybind11_tests.sequences_and_iterators.Sequence object at 0x138aa3885c70>
../../pybind11-3.0.3/tests/test_sequences_and_iterators.py:125: AssertionError
------------------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------------------
### test_submodule_sequences_and_iterators(module_&)::Sequence @ 0x13899bbf9e00 created of size 5
____________________________________________________________________________ test_methods_and_attributes ____________________________________________________________________________
def test_methods_and_attributes():
instance1 = m.ExampleMandA()
instance2 = m.ExampleMandA(32)
instance1.add1(instance2)
instance1.add2(instance2)
instance1.add3(instance2)
instance1.add4(instance2)
instance1.add5(instance2)
instance1.add6(32)
instance1.add7(32)
instance1.add8(32)
instance1.add9(32)
instance1.add10(32)
assert str(instance1) == "ExampleMandA[value=320]"
assert str(instance2) == "ExampleMandA[value=32]"
assert str(instance1.self1()) == "ExampleMandA[value=320]"
assert str(instance1.self2()) == "ExampleMandA[value=320]"
assert str(instance1.self3()) == "ExampleMandA[value=320]"
assert str(instance1.self4()) == "ExampleMandA[value=320]"
assert str(instance1.self5()) == "ExampleMandA[value=320]"
assert instance1.internal1() == 320
assert instance1.internal2() == 320
assert instance1.internal3() == 320
assert instance1.internal4() == 320
assert instance1.internal5() == 320
assert instance1.overloaded() == "()"
assert instance1.overloaded(0) == "(int)"
assert instance1.overloaded(1, 1.0) == "(int, float)"
assert instance1.overloaded(2.0, 2) == "(float, int)"
assert instance1.overloaded(3, 3) == "(int, int)"
assert instance1.overloaded(4.0, 4.0) == "(float, float)"
assert instance1.overloaded_const(-3) == "(int) const"
assert instance1.overloaded_const(5, 5.0) == "(int, float) const"
assert instance1.overloaded_const(6.0, 6) == "(float, int) const"
assert instance1.overloaded_const(7, 7) == "(int, int) const"
assert instance1.overloaded_const(8.0, 8.0) == "(float, float) const"
assert instance1.overloaded_float(1, 1) == "(float, float)"
assert instance1.overloaded_float(1, 1.0) == "(float, float)"
assert instance1.overloaded_float(1.0, 1) == "(float, float)"
assert instance1.overloaded_float(1.0, 1.0) == "(float, float)"
assert instance1.value == 320
instance1.value = 100
assert str(instance1) == "ExampleMandA[value=100]"
if env.GRAALPY:
pytest.skip("ConstructorStats is incompatible with GraalPy.")
cstats = ConstructorStats.get(m.ExampleMandA)
assert cstats.alive() == 2
del instance1, instance2
assert cstats.alive() == 0
> assert cstats.values() == ["32"]
E AssertionError: assert ['123', '-100...', '-7', '32'] == ['32']
E
E At index 0 diff: '123' != '32'
E Left contains 5 more items, first extra item: '-100'
E Use -v to get more diff
cstats = <pybind11_tests.ConstructorStats object at 0x138aa370d130>
../../pybind11-3.0.3/tests/test_methods_and_attributes.py:85: AssertionError
------------------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------------------
### ExampleMandA @ 0x138aa26db740 created via default constructor
### ExampleMandA @ 0x138aa26db750 created 32
### ExampleMandA @ 0x8211c1d50 created via copy constructor
### ExampleMandA @ 0x8211c1d54 created via move constructor
### ExampleMandA @ 0x8211c1d54 destroyed
### ExampleMandA @ 0x8211c1d50 destroyed
### ExampleMandA @ 0x8211c1d7c created via copy constructor
### ExampleMandA @ 0x138aa26db798 created via move constructor
### ExampleMandA @ 0x8211c1d7c destroyed
### ExampleMandA @ 0x138aa26db798 destroyed
### ExampleMandA @ 0x138aa26db740 destroyed
### ExampleMandA @ 0x138aa26db750 destroyed
______________________________________________________________________________ test_init_factory_basic ______________________________________________________________________________
@pytest.mark.skipif("env.GRAALPY", reason="Cannot reliably trigger GC")
def test_init_factory_basic():
"""Tests py::init_factory() wrapper around various ways of returning the object"""
cstats = [
ConstructorStats.get(c)
for c in [m.TestFactory1, m.TestFactory2, m.TestFactory3]
]
cstats[0].alive() # force gc
n_inst = ConstructorStats.detail_reg_inst()
x1 = m.TestFactory1(tag.unique_ptr, 3)
assert x1.value == "3"
y1 = m.TestFactory1(tag.pointer)
assert y1.value == "(empty)"
z1 = m.TestFactory1("hi!")
assert z1.value == "hi!"
assert ConstructorStats.detail_reg_inst() == n_inst + 3
x2 = m.TestFactory2(tag.move)
assert x2.value == "(empty2)"
y2 = m.TestFactory2(tag.pointer, 7)
assert y2.value == "7"
z2 = m.TestFactory2(tag.unique_ptr, "hi again")
assert z2.value == "hi again"
assert ConstructorStats.detail_reg_inst() == n_inst + 6
x3 = m.TestFactory3(tag.shared_ptr)
assert x3.value == "(empty3)"
y3 = m.TestFactory3(tag.pointer, 42)
assert y3.value == "42"
z3 = m.TestFactory3("bye")
assert z3.value == "bye"
for null_ptr_kind in [tag.null_ptr, tag.null_unique_ptr, tag.null_shared_ptr]:
with pytest.raises(TypeError) as excinfo:
m.TestFactory3(null_ptr_kind)
assert (
str(excinfo.value) == "pybind11::init(): factory function returned nullptr"
)
assert [i.alive() for i in cstats] == [3, 3, 3]
assert ConstructorStats.detail_reg_inst() == n_inst + 9
del x1, y2, y3, z3
assert [i.alive() for i in cstats] == [2, 2, 1]
assert ConstructorStats.detail_reg_inst() == n_inst + 5
del x2, x3, y1, z1, z2
assert [i.alive() for i in cstats] == [0, 0, 0]
assert ConstructorStats.detail_reg_inst() == n_inst
> assert [i.values() for i in cstats] == [
["3", "hi!"],
["7", "hi again"],
["42", "bye"],
]
E AssertionError: assert [['3', 'hi!']...['42', 'bye']] == [['3', 'hi!']...['42', 'bye']]
E
E At index 1 diff: ['1', '1', '1', '7', 'hi again'] != ['7', 'hi again']
E Use -v to get more diff
cstats = [<pybind11_tests.ConstructorStats object at 0x138aa3d97570>, <pybind11_tests.ConstructorStats object at 0x138aa3d956b0>, <pybind11_tests.ConstructorStats object at 0x138aa3d952b0>]
excinfo = <ExceptionInfo TypeError('pybind11::init(): factory function returned nullptr') tblen=1>
n_inst = 92
null_ptr_kind = <pybind11_tests.factory_constructors.tag.null_shared_ptr_tag object at 0x138aa0c553b0>
../../pybind11-3.0.3/tests/test_factory_constructors.py:66: AssertionError
stance1.value = 100
assert str(instance1) == "ExampleMandA[value=100]"
if env.GRAALPY:
pytest.skip("ConstructorStats is incompatible with GraalPy.")
cstats = ConstructorStats.get(m.ExampleMandA)
assert cstats.alive() == 2
del instance1, instance2
assert cstats.alive() == 0
> assert cstats.values() == ["32"]
E AssertionError: assert ['123', '-100...', '-7', '32'] == ['32']
E
E At index 0 diff: '123' != '32'
E Left contains 5 more items, first extra item: '-100'
E Use -v to get more diff
cstats = <pybind11_tests.ConstructorStats object at 0x138aa370d130>
../../pybind11-3.0.3/tests/test_methods_and_attributes.py:85: AssertionError
------------------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------------------
### ExampleMandA @ 0x138aa26db740 created via default constructor
### ExampleMandA @ 0x138aa26db750 created 32
### ExampleMandA @ 0x8211c1d50 created via copy constructor
### ExampleMandA @ 0x8211c1d54 created via move constructor
### ExampleMandA @ 0x8211c1d54 destroyed
### ExampleMandA @ 0x8211c1d50 destroyed
### ExampleMandA @ 0x8211c1d7c created via copy constructor
### ExampleMandA @ 0x138aa26db798 created via move constructor
### ExampleMandA @ 0x8211c1d7c destroyed
### ExampleMandA @ 0x138aa26db798 destroyed
### ExampleMandA @ 0x138aa26db740 destroyed
### ExampleMandA @ 0x138aa26db750 destroyed
______________________________________________________________________________ test_init_factory_basic ______________________________________________________________________________
@pytest.mark.skipif("env.GRAALPY", reason="Cannot reliably trigger GC")
def test_init_factory_basic():
"""Tests py::init_factory() wrapper around various ways of returning the object"""
cstats = [
ConstructorStats.get(c)
for c in [m.TestFactory1, m.TestFactory2, m.TestFactory3]
]
cstats[0].alive() # force gc
n_inst = ConstructorStats.detail_reg_inst()
x1 = m.TestFactory1(tag.unique_ptr, 3)
assert x1.value == "3"
y1 = m.TestFactory1(tag.pointer)
assert y1.value == "(empty)"
z1 = m.TestFactory1("hi!")
assert z1.value == "hi!"
assert ConstructorStats.detail_reg_inst() == n_inst + 3
x2 = m.TestFactory2(tag.move)
assert x2.value == "(empty2)"
y2 = m.TestFactory2(tag.pointer, 7)
assert y2.value == "7"
z2 = m.TestFactory2(tag.unique_ptr, "hi again")
assert z2.value == "hi again"
assert ConstructorStats.detail_reg_inst() == n_inst + 6
x3 = m.TestFactory3(tag.shared_ptr)
assert x3.value == "(empty3)"
y3 = m.TestFactory3(tag.pointer, 42)
assert y3.value == "42"
z3 = m.TestFactory3("bye")
assert z3.value == "bye"
for null_ptr_kind in [tag.null_ptr, tag.null_unique_ptr, tag.null_shared_ptr]:
with pytest.raises(TypeError) as excinfo:
m.TestFactory3(null_ptr_kind)
assert (
str(excinfo.value) == "pybind11::init(): factory function returned nullptr"
)
assert [i.alive() for i in cstats] == [3, 3, 3]
assert ConstructorStats.detail_reg_inst() == n_inst + 9
del x1, y2, y3, z3
assert [i.alive() for i in cstats] == [2, 2, 1]
assert ConstructorStats.detail_reg_inst() == n_inst + 5
del x2, x3, y1, z1, z2
assert [i.alive() for i in cstats] == [0, 0, 0]
assert ConstructorStats.detail_reg_inst() == n_inst
> assert [i.values() for i in cstats] == [
["3", "hi!"],
["7", "hi again"],
["42", "bye"],
]
E AssertionError: assert [['3', 'hi!']...['42', 'bye']] == [['3', 'hi!']...['42', 'bye']]
E
E At index 1 diff: ['1', '1', '1', '7', 'hi again'] != ['7', 'hi again']
E Use -v to get more diff
cstats = [<pybind11_tests.ConstructorStats object at 0x138aa3d97570>, <pybind11_tests.ConstructorStats object at 0x138aa3d956b0>, <pybind11_tests.ConstructorStats object at 0x138aa3d952b0>]
excinfo = <ExceptionInfo TypeError('pybind11::init(): factory function returned nullptr') tblen=1>
n_inst = 92
null_ptr_kind = <pybind11_tests.factory_constructors.tag.null_shared_ptr_tag object at 0x138aa0c553b0>
../../pybind11-3.0.3/tests/test_factory_constructors.py:66: AssertionError
bind11_builtins.pybind11_detail_function_record_v1_system_libcpp_abi1 object at 0x138aa0c64490>(array([[ 0., 22., 20.],\n [31., 37., 33.],\n [41., 42., 38.]]))
E + where <built-in method cpp_copy of pybind11_builtins.pybind11_detail_function_record_v1_system_libcpp_abi1 object at 0x138aa0c64490> = m.cpp_copy
E + and array([[ 0., 22., 20.],\n [31., 37., 33.],\n [41., 42., 38.]]) = <built-in method get_cm_ref of pybind11_builtins.pybind11_detail_function_record_v1_system_libcpp_abi1 object at 0x138aa0c3fdd0>()
E + where <built-in method get_cm_ref of pybind11_builtins.pybind11_detail_function_record_v1_system_libcpp_abi1 object at 0x138aa0c3fdd0> = m.get_cm_ref
z = array([[5., 6.],
[7., 8.]])
../../pybind11-3.0.3/tests/test_eigen_matrix.py:125: AssertionError
___________________________________________________________________________________ test_sequence ___________________________________________________________________________________
def test_sequence():
cstats = ConstructorStats.get(m.Sequence)
s = m.Sequence(5)
if not env.GRAALPY:
> assert cstats.values() == ["of size", "5"]
E AssertionError: assert ['of size', '...of size', '5'] == ['of size', '5']
E
E Left contains 2 more items, first extra item: 'of size'
E Use -v to get more diff
cstats = <pybind11_tests.ConstructorStats object at 0x138aa3885db0>
s = <pybind11_tests.sequences_and_iterators.Sequence object at 0x138aa3885c70>
../../pybind11-3.0.3/tests/test_sequences_and_iterators.py:125: AssertionError
------------------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------------------
### test_submodule_sequences_and_iterators(module_&)::Sequence @ 0x13899bbf9e00 created of size 5
____________________________________________________________________________ test_methods_and_attributes ____________________________________________________________________________
def test_methods_and_attributes():
instance1 = m.ExampleMandA()
instance2 = m.ExampleMandA(32)
instance1.add1(instance2)
instance1.add2(instance2)
instance1.add3(instance2)
instance1.add4(instance2)
instance1.add5(instance2)
instance1.add6(32)
instance1.add7(32)
instance1.add8(32)
instance1.add9(32)
instance1.add10(32)
assert str(instance1) == "ExampleMandA[value=320]"
assert str(instance2) == "ExampleMandA[value=32]"
assert str(instance1.self1()) == "ExampleMandA[value=320]"
assert str(instance1.self2()) == "ExampleMandA[value=320]"
assert str(instance1.self3()) == "ExampleMandA[value=320]"
assert str(instance1.self4()) == "ExampleMandA[value=320]"
assert str(instance1.self5()) == "ExampleMandA[value=320]"
assert instance1.internal1() == 320
assert instance1.internal2() == 320
assert instance1.internal3() == 320
assert instance1.internal4() == 320
assert instance1.internal5() == 320
assert instance1.overloaded() == "()"
assert instance1.overloaded(0) == "(int)"
assert instance1.overloaded(1, 1.0) == "(int, float)"
assert instance1.overloaded(2.0, 2) == "(float, int)"
assert instance1.overloaded(3, 3) == "(int, int)"
assert instance1.overloaded(4.0, 4.0) == "(float, float)"
assert instance1.overloaded_const(-3) == "(int) const"
assert instance1.overloaded_const(5, 5.0) == "(int, float) const"
assert instance1.overloaded_const(6.0, 6) == "(float, int) const"
assert instance1.overloaded_const(7, 7) == "(int, int) const"
assert instance1.overloaded_const(8.0, 8.0) == "(float, float) const"
assert instance1.overloaded_float(1, 1) == "(float, float)"
assert instance1.overloaded_float(1, 1.0) == "(float, float)"
assert instance1.overloaded_float(1.0, 1) == "(float, float)"
assert instance1.overloaded_float(1.0, 1.0) == "(float, float)"
assert instance1.value == 320
instance1.value = 100
assert str(instance1) == "ExampleMandA[value=100]"
if env.GRAALPY:
pytest.skip("ConstructorStats is incompatible with GraalPy.")
cstats = ConstructorStats.get(m.ExampleMandA)
assert cstats.alive() == 2
del instance1, instance2
assert cstats.alive() == 0
> assert cstats.values() == ["32"]
E AssertionError: assert ['123', '-100...', '-7', '32'] == ['32']
E
E At index 0 diff: '123' != '32'
E Left contains 5 more items, first extra item: '-100'
E Use -v to get more diff
cstats = <pybind11_tests.ConstructorStats object at 0x138aa370d130>
../../pybind11-3.0.3/tests/test_methods_and_attributes.py:85: AssertionError
------------------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------------------
### ExampleMandA @ 0x138aa26db740 created via default constructor
### ExampleMandA @ 0x138aa26db750 created 32
### ExampleMandA @ 0x8211c1d50 created via copy constructor
### ExampleMandA @ 0x8211c1d54 created via move constructor
### ExampleMandA @ 0x8211c1d54 destroyed
### ExampleMandA @ 0x8211c1d50 destroyed
### ExampleMandA @ 0x8211c1d7c created via copy constructor
### ExampleMandA @ 0x138aa26db798 created via move constructor
### ExampleMandA @ 0x8211c1d7c destroyed
### ExampleMandA @ 0x138aa26db798 destroyed
### ExampleMandA @ 0x138aa26db740 destroyed
### ExampleMandA @ 0x138aa26db750 destroyed
______________________________________________________________________________ test_init_factory_basic ______________________________________________________________________________
@pytest.mark.skipif("env.GRAALPY", reason="Cannot reliably trigger GC")
def test_init_factory_basic():
"""Tests py::init_factory() wrapper around various ways of returning the object"""
cstats = [
ConstructorStats.get(c)
for c in [m.TestFactory1, m.TestFactory2, m.TestFactory3]
]
cstats[0].alive() # force gc
n_inst = ConstructorStats.detail_reg_inst()
x1 = m.TestFactory1(tag.unique_ptr, 3)
assert x1.value == "3"
y1 = m.TestFactory1(tag.pointer)
assert y1.value == "(empty)"
z1 = m.TestFactory1("hi!")
assert z1.value == "hi!"
assert ConstructorStats.detail_reg_inst() == n_inst + 3
x2 = m.TestFactory2(tag.move)
assert x2.value == "(empty2)"
y2 = m.TestFactory2(tag.pointer, 7)
assert y2.value == "7"
z2 = m.TestFactory2(tag.unique_ptr, "hi again")
assert z2.value == "hi again"
assert ConstructorStats.detail_reg_inst() == n_inst + 6
x3 = m.TestFactory3(tag.shared_ptr)
assert x3.value == "(empty3)"
y3 = m.TestFactory3(tag.pointer, 42)
assert y3.value == "42"
z3 = m.TestFactory3("bye")
assert z3.value == "bye"
for null_ptr_kind in [tag.null_ptr, tag.null_unique_ptr, tag.null_shared_ptr]:
with pytest.raises(TypeError) as excinfo:
m.TestFactory3(null_ptr_kind)
assert (
str(excinfo.value) == "pybind11::init(): factory function returned nullptr"
)
assert [i.alive() for i in cstats] == [3, 3, 3]
assert ConstructorStats.detail_reg_inst() == n_inst + 9
del x1, y2, y3, z3
assert [i.alive() for i in cstats] == [2, 2, 1]
assert ConstructorStats.detail_reg_inst() == n_inst + 5
del x2, x3, y1, z1, z2
assert [i.alive() for i in cstats] == [0, 0, 0]
assert ConstructorStats.detail_reg_inst() == n_inst
> assert [i.values() for i in cstats] == [
["3", "hi!"],
["7", "hi again"],
["42", "bye"],
]
E AssertionError: assert [['3', 'hi!']...['42', 'bye']] == [['3', 'hi!']...['42', 'bye']]
E
E At index 1 diff: ['1', '1', '1', '7', 'hi again'] != ['7', 'hi again']
E Use -v to get more diff
cstats = [<pybind11_tests.ConstructorStats object at 0x138aa3d97570>, <pybind11_tests.ConstructorStats object at 0x138aa3d956b0>, <pybind11_tests.ConstructorStats object at 0x138aa3d952b0>]
excinfo = <ExceptionInfo TypeError('pybind11::init(): factory function returned nullptr') tblen=1>
n_inst = 92
null_ptr_kind = <pybind11_tests.factory_constructors.tag.null_shared_ptr_tag object at 0x138aa0c553b0>
../../pybind11-3.0.3/tests/test_factory_constructors.py:66: AssertionError
Required prerequisites
What version (or hash if on master) of pybind11 are you using?
3.0.3
Problem description
Here are failure messages:
Reproducible example code
Is this a regression? Put the last known working version here if it is.
Not a regression