| 942 | |
| 943 | |
| 944 | def test_buffer_memoryview_is_immutable(): |
| 945 | val = b'some data' |
| 946 | |
| 947 | buf = pa.py_buffer(val) |
| 948 | assert not buf.is_mutable |
| 949 | assert isinstance(buf, pa.Buffer) |
| 950 | |
| 951 | result = memoryview(buf) |
| 952 | assert result.readonly |
| 953 | |
| 954 | with pytest.raises(TypeError) as exc: |
| 955 | result[0] = b'h' |
| 956 | assert 'cannot modify read-only' in str(exc.value) |
| 957 | |
| 958 | b = bytes(buf) |
| 959 | with pytest.raises(TypeError) as exc: |
| 960 | b[0] = b'h' |
| 961 | assert 'cannot modify read-only' in str(exc.value) |
| 962 | |
| 963 | |
| 964 | def test_uninitialized_buffer(): |