(self)
| 751 | } |
| 752 | |
| 753 | def test_chunker_out_of_sync(self): |
| 754 | # GH-39892: if there are newlines in values, the parser may become |
| 755 | # out of sync with the chunker. In this case, we try to produce an |
| 756 | # informative error message. |
| 757 | rows = b"""a,b,c\nd,e,"f\n"\ng,h,i\n""" |
| 758 | expected = { |
| 759 | 'a': ["d", "g"], |
| 760 | 'b': ["e", "h"], |
| 761 | 'c': ["f\n", "i"], |
| 762 | } |
| 763 | for block_size in range(8, 15): |
| 764 | # Sanity check: parsing works with newlines_in_values=True |
| 765 | d = self.read_bytes( |
| 766 | rows, parse_options=ParseOptions(newlines_in_values=True), |
| 767 | read_options=ReadOptions(block_size=block_size)).to_pydict() |
| 768 | assert d == expected |
| 769 | # With these block sizes, a block would end on the physical newline |
| 770 | # inside the quoted cell value, leading to a mismatch between |
| 771 | # CSV chunker and parser. |
| 772 | for block_size in range(8, 11): |
| 773 | with pytest.raises(ValueError, |
| 774 | match="cell values spanning multiple lines"): |
| 775 | self.read_bytes( |
| 776 | rows, read_options=ReadOptions(block_size=block_size)) |
| 777 | |
| 778 | |
| 779 | class BaseCSVTableRead(BaseTestCSV): |
nothing calls this directly
no test coverage detected