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