| 117 | |
| 118 | @require_pil |
| 119 | def test_csv_cast_image(csv_file_with_image): |
| 120 | with open(csv_file_with_image, encoding="utf-8") as f: |
| 121 | image_file = f.read().splitlines()[1] |
| 122 | csv = Csv(encoding="utf-8", features=Features({"image": Image()})) |
| 123 | base_files = [csv_file_with_image] |
| 124 | files_iterables = [[file] for file in base_files] |
| 125 | generator = csv._generate_tables(base_files=base_files, files_iterables=files_iterables) |
| 126 | pa_table = pa.concat_tables([table for _, table in generator]) |
| 127 | assert pa_table.schema.field("image").type == Image()() |
| 128 | generated_content = pa_table.to_pydict()["image"] |
| 129 | assert generated_content == [{"path": image_file, "bytes": None}] |
| 130 | |
| 131 | |
| 132 | def test_csv_cast_label(csv_file_with_label): |