MCPcopy Create free account
hub / github.com/apache/arrow / test_invalid_csv

Method test_invalid_csv

python/pyarrow/tests/test_csv.py:1668–1688  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1666 reader.read_next_batch()
1667
1668 def test_invalid_csv(self):
1669 # CSV errors on first block
1670 rows = b"a,b\n1,2,3\n4,5\n6,7\n"
1671 read_options = ReadOptions()
1672 read_options.block_size = 10
1673 with pytest.raises(pa.ArrowInvalid,
1674 match="Expected 2 columns, got 3"):
1675 reader = self.open_bytes(
1676 rows, read_options=read_options)
1677
1678 # CSV errors on second block
1679 rows = b"a,b\n1,2\n3,4,5\n6,7\n"
1680 read_options.block_size = 8
1681 reader = self.open_bytes(rows, read_options=read_options)
1682 assert reader.read_next_batch().to_pydict() == {'a': [1], 'b': [2]}
1683 with pytest.raises(pa.ArrowInvalid,
1684 match="Expected 2 columns, got 3"):
1685 reader.read_next_batch()
1686 # Cannot continue after a parse error
1687 with pytest.raises(StopIteration):
1688 reader.read_next_batch()
1689
1690 def test_options_delimiter(self):
1691 rows = b"a;b,c\nde,fg;eh\n"

Callers

nothing calls this directly

Calls 2

open_bytesMethod · 0.95
ReadOptionsClass · 0.90

Tested by

no test coverage detected