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

Function test_read_options

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

Source from the content-addressed store, hash-verified

160
161
162def test_read_options(pickle_module):
163 cls = ReadOptions
164 opts = cls()
165
166 check_options_class(cls, use_threads=[True, False],
167 skip_rows=[0, 3],
168 column_names=[[], ["ab", "cd"]],
169 autogenerate_column_names=[False, True],
170 encoding=['utf8', 'utf16'],
171 skip_rows_after_names=[0, 27])
172
173 check_options_class_pickling(cls, pickler=pickle_module,
174 use_threads=True,
175 skip_rows=3,
176 column_names=["ab", "cd"],
177 autogenerate_column_names=False,
178 encoding='utf16',
179 skip_rows_after_names=27)
180
181 assert opts.block_size > 0
182 opts.block_size = 12345
183 assert opts.block_size == 12345
184
185 opts = cls(block_size=1234)
186 assert opts.block_size == 1234
187
188 opts.validate()
189
190 match = "ReadOptions: block_size must be at least 1: 0"
191 with pytest.raises(pa.ArrowInvalid, match=match):
192 opts = cls()
193 opts.block_size = 0
194 opts.validate()
195
196 match = "ReadOptions: skip_rows cannot be negative: -1"
197 with pytest.raises(pa.ArrowInvalid, match=match):
198 opts = cls()
199 opts.skip_rows = -1
200 opts.validate()
201
202 match = "ReadOptions: skip_rows_after_names cannot be negative: -1"
203 with pytest.raises(pa.ArrowInvalid, match=match):
204 opts = cls()
205 opts.skip_rows_after_names = -1
206 opts.validate()
207
208 match = "ReadOptions: autogenerate_column_names cannot be true when" \
209 " column_names are provided"
210 with pytest.raises(pa.ArrowInvalid, match=match):
211 opts = cls()
212 opts.autogenerate_column_names = True
213 opts.column_names = ('a', 'b')
214 opts.validate()
215
216 expected_repr_inner = """
217 use_threads=True,
218 block_size=1048576,
219 skip_rows=0,

Callers

nothing calls this directly

Calls 3

check_options_classFunction · 0.85
validateMethod · 0.45

Tested by

no test coverage detected