| 883 | |
| 884 | |
| 885 | def test_sequence_bytes(): |
| 886 | u1 = b'ma\xc3\xb1ana' |
| 887 | |
| 888 | data = [b'foo', |
| 889 | memoryview(b'dada'), |
| 890 | memoryview(b'd-a-t-a')[::2], # non-contiguous is made contiguous |
| 891 | u1.decode('utf-8'), # unicode gets encoded, |
| 892 | bytearray(b'bar'), |
| 893 | None] |
| 894 | for ty in [None, pa.binary(), pa.large_binary(), pa.binary_view()]: |
| 895 | arr = pa.array(data, type=ty) |
| 896 | assert len(arr) == 6 |
| 897 | assert arr.null_count == 1 |
| 898 | assert arr.type == ty or pa.binary() |
| 899 | assert arr.to_pylist() == [b'foo', b'dada', b'data', u1, b'bar', None] |
| 900 | |
| 901 | |
| 902 | @pytest.mark.parametrize("ty", [pa.string(), pa.large_string(), pa.string_view()]) |