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

Function mockfs

python/pyarrow/tests/test_dataset.py:116–147  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

114
115@pytest.fixture
116def mockfs():
117 mockfs = fs._MockFileSystem()
118
119 directories = [
120 'subdir/1/xxx',
121 'subdir/2/yyy',
122 ]
123
124 for i, directory in enumerate(directories):
125 path = f'{directory}/file{i}.parquet'
126 mockfs.create_dir(directory)
127 with mockfs.open_output_stream(path) as out:
128 data = [
129 list(range(5)),
130 list(map(float, range(5))),
131 list(map(str, range(5))),
132 [i] * 5,
133 [{'a': j % 3, 'b': str(j % 3)} for j in range(5)],
134 ]
135 schema = pa.schema([
136 ('i64', pa.int64()),
137 ('f64', pa.float64()),
138 ('str', pa.string()),
139 ('const', pa.int64()),
140 ('struct', pa.struct({'a': pa.int64(), 'b': pa.string()})),
141 ])
142 batch = pa.record_batch(data, schema=schema)
143 table = pa.Table.from_batches([batch])
144
145 pq.write_table(table, out)
146
147 return mockfs
148
149
150@pytest.fixture

Callers

nothing calls this directly

Calls 7

listFunction · 0.85
mapFunction · 0.85
create_dirMethod · 0.45
open_output_streamMethod · 0.45
schemaMethod · 0.45
stringMethod · 0.45
write_tableMethod · 0.45

Tested by

no test coverage detected