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

Method test_invalid_csv

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

Source from the content-addressed store, hash-verified

1737 reader.read_next_batch()
1738
1739 def test_invalid_csv(self):
1740 # CSV errors on first block
1741 rows = b"a,b\n1,2,3\n4,5\n6,7\n"
1742 read_options = ReadOptions()
1743 read_options.block_size = 10
1744 with pytest.raises(pa.ArrowInvalid,
1745 match="Expected 2 columns, got 3"):
1746 reader = self.open_bytes(
1747 rows, read_options=read_options)
1748
1749 # CSV errors on second block
1750 rows = b"a,b\n1,2\n3,4,5\n6,7\n"
1751 read_options.block_size = 8
1752 reader = self.open_bytes(rows, read_options=read_options)
1753 assert reader.read_next_batch().to_pydict() == {'a': [1], 'b': [2]}
1754 with pytest.raises(pa.ArrowInvalid,
1755 match="Expected 2 columns, got 3"):
1756 reader.read_next_batch()
1757 # Cannot continue after a parse error
1758 with pytest.raises(StopIteration):
1759 reader.read_next_batch()
1760
1761 def test_options_delimiter(self):
1762 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