def test_codes_get_array_errors(): grib = eccodes.codes_handle_new_from_file(open(TEST_DATA)) with pytest.raises(eccodes.EcCodesError) as err: eccodes.codes_get_array(grib, b'values', size=1) # too short assert err.value.code == eccodes.lib.GRIB_ARRAY_TOO_SMALL with pytest.raises(eccodes.EcCodesError) as err: eccodes.codes_get_array(grib, b'values', key_type=eccodes.CODES_TYPE_LONG) # wrong type assert err.value.code == eccodes.lib.GRIB_NOT_IMPLEMENTED
def test_codes_get_array(key, expected_value): grib = eccodes.codes_handle_new_from_file(open(TEST_DATA)) result = eccodes.codes_get_array(grib, key) assert result == expected_value