| 860 | |
| 861 | |
| 862 | def test_sequence_bytes(): |
| 863 | u1 = b'ma\xc3\xb1ana' |
| 864 | |
| 865 | data = [b'foo', |
| 866 | memoryview(b'dada'), |
| 867 | memoryview(b'd-a-t-a')[::2], # non-contiguous is made contiguous |
| 868 | u1.decode('utf-8'), # unicode gets encoded, |
| 869 | bytearray(b'bar'), |
| 870 | None] |
| 871 | for ty in [None, pa.binary(), pa.large_binary(), pa.binary_view()]: |
| 872 | arr = pa.array(data, type=ty) |
| 873 | assert len(arr) == 6 |
| 874 | assert arr.null_count == 1 |
| 875 | assert arr.type == ty or pa.binary() |
| 876 | assert arr.to_pylist() == [b'foo', b'dada', b'data', u1, b'bar', None] |
| 877 | |
| 878 | |
| 879 | @pytest.mark.parametrize("ty", [pa.string(), pa.large_string(), pa.string_view()]) |