def test_scalar_conversion(): from pybind11_tests import (create_rec_simple, f_simple, create_rec_packed, f_packed, create_rec_nested, f_nested, create_enum_array) n = 3 arrays = [ create_rec_simple(n), create_rec_packed(n), create_rec_nested(n), create_enum_array(n) ] funcs = [f_simple, f_packed, f_nested] for i, func in enumerate(funcs): for j, arr in enumerate(arrays): if i == j and i < 2: if [func(arr[k]) for k in range(n)] != [k * 10 for k in range(n)]: raise AssertionError else: with pytest.raises(TypeError) as excinfo: func(arr[0]) if 'incompatible function arguments' not in str(excinfo.value): raise AssertionError
def test_scalar_conversion(): from pybind11_tests import (create_rec_simple, f_simple, create_rec_packed, f_packed, create_rec_nested, f_nested, create_enum_array) n = 3 arrays = [create_rec_simple(n), create_rec_packed(n), create_rec_nested(n), create_enum_array(n)] funcs = [f_simple, f_packed, f_nested] for i, func in enumerate(funcs): for j, arr in enumerate(arrays): if i == j and i < 2: assert [func(arr[k]) for k in range(n)] == [k * 10 for k in range(n)] else: with pytest.raises(TypeError) as excinfo: func(arr[0]) assert 'incompatible function arguments' in str(excinfo.value)