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