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

Method test_chunker_out_of_sync

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

Source from the content-addressed store, hash-verified

766 }
767
768 def test_chunker_out_of_sync(self):
769 # GH-39892: if there are newlines in values, the parser may become
770 # out of sync with the chunker. In this case, we try to produce an
771 # informative error message.
772 rows = b"""a,b,c\nd,e,"f\n"\ng,h,i\n"""
773 expected = {
774 'a': ["d", "g"],
775 'b': ["e", "h"],
776 'c': ["f\n", "i"],
777 }
778 for block_size in range(8, 15):
779 # Sanity check: parsing works with newlines_in_values=True
780 d = self.read_bytes(
781 rows, parse_options=ParseOptions(newlines_in_values=True),
782 read_options=ReadOptions(block_size=block_size)).to_pydict()
783 assert d == expected
784 # With these block sizes, a block would end on the physical newline
785 # inside the quoted cell value, leading to a mismatch between
786 # CSV chunker and parser.
787 for block_size in range(8, 11):
788 with pytest.raises(ValueError,
789 match="cell values spanning multiple lines"):
790 self.read_bytes(
791 rows, read_options=ReadOptions(block_size=block_size))
792
793
794class BaseCSVTableRead(BaseTestCSV):

Callers

nothing calls this directly

Calls 3

read_bytesMethod · 0.95
ParseOptionsClass · 0.90
ReadOptionsClass · 0.90

Tested by

no test coverage detected