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

Function test_parse_options

python/pyarrow/tests/test_csv.py:229–298  ·  view source on GitHub ↗
(pickle_module)

Source from the content-addressed store, hash-verified

227
228
229def test_parse_options(pickle_module):
230 cls = ParseOptions
231 skip_handler = InvalidRowHandler('skip')
232
233 check_options_class(cls, delimiter=[',', 'x'],
234 escape_char=[False, 'y'],
235 quote_char=['"', 'z', False],
236 double_quote=[True, False],
237 newlines_in_values=[False, True],
238 ignore_empty_lines=[True, False],
239 invalid_row_handler=[None, skip_handler])
240
241 check_options_class_pickling(cls, pickler=pickle_module,
242 delimiter='x',
243 escape_char='y',
244 quote_char=False,
245 double_quote=False,
246 newlines_in_values=True,
247 ignore_empty_lines=False,
248 invalid_row_handler=skip_handler)
249
250 cls().validate()
251 opts = cls()
252 opts.delimiter = "\t"
253 opts.validate()
254
255 match = "ParseOptions: delimiter cannot be \\\\r or \\\\n"
256 with pytest.raises(pa.ArrowInvalid, match=match):
257 opts = cls()
258 opts.delimiter = "\n"
259 opts.validate()
260
261 with pytest.raises(pa.ArrowInvalid, match=match):
262 opts = cls()
263 opts.delimiter = "\r"
264 opts.validate()
265
266 match = "ParseOptions: quote_char cannot be \\\\r or \\\\n"
267 with pytest.raises(pa.ArrowInvalid, match=match):
268 opts = cls()
269 opts.quote_char = "\n"
270 opts.validate()
271
272 with pytest.raises(pa.ArrowInvalid, match=match):
273 opts = cls()
274 opts.quote_char = "\r"
275 opts.validate()
276
277 match = "ParseOptions: escape_char cannot be \\\\r or \\\\n"
278 with pytest.raises(pa.ArrowInvalid, match=match):
279 opts = cls()
280 opts.escape_char = "\n"
281 opts.validate()
282
283 with pytest.raises(pa.ArrowInvalid, match=match):
284 opts = cls()
285 opts.escape_char = "\r"
286 opts.validate()

Callers

nothing calls this directly

Calls 4

InvalidRowHandlerClass · 0.85
check_options_classFunction · 0.85
validateMethod · 0.45

Tested by

no test coverage detected