Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-37555: [Python] Update get_file_info_selector to ignore base directory #37558

Merged
merged 8 commits into from
Sep 14, 2023
18 changes: 10 additions & 8 deletions python/pyarrow/tests/test_fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,10 @@ def test_get_file_info_with_selector(fs, pathfn):
# on the s3fs/fsspec version combo, it includes the base_dir
# (https://github.com/dask/s3fs/issues/393)
assert (len(infos) == 4) or (len(infos) == 5)
elif fs.type_name in ["py::fsspec+file", 'py::fsspec+memory']:
# fsspec also lists root dir
# GH-37555
AlenkaF marked this conversation as resolved.
Show resolved Hide resolved
assert len(infos) == 6
else:
assert len(infos) == 5

Expand All @@ -713,9 +717,9 @@ def test_get_file_info_with_selector(fs, pathfn):
elif (info.path.rstrip("/").endswith(dir_a) or
info.path.rstrip("/").endswith(dir_b)):
assert info.type == FileType.Directory
elif (fs.type_name == "py::fsspec+s3" and
elif ("py::fsspec" in fs.type_name and
info.path.rstrip("/").endswith("selector-dir")):
# s3fs can include base dir, see above
# fsspec can include base dir, see above
assert info.type == FileType.Directory
else:
raise ValueError('unexpected path {}'.format(info.path))
Expand All @@ -725,12 +729,10 @@ def test_get_file_info_with_selector(fs, pathfn):
selector = FileSelector(base_dir, recursive=False)

infos = fs.get_file_info(selector)
if fs.type_name == "py::fsspec+s3":
# s3fs only lists directories if they are not empty
# + for s3fs 0.5.2 all directories are dropped because of buggy
# side-effect of previous find() call
# (https://github.com/dask/s3fs/issues/410)
assert (len(infos) == 3) or (len(infos) == 2)
if fs.type_name in ["py::fsspec+file", 'py::fsspec+memory']:
# fsspec also lists root dir
# GH-37555
assert len(infos) == 5
else:
assert len(infos) == 4

Expand Down
Loading