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

Function test_get_file_info

python/pyarrow/tests/test_fs.py:720–776  ·  view source on GitHub ↗
(fs, pathfn)

Source from the content-addressed store, hash-verified

718
719
720def test_get_file_info(fs, pathfn):
721 aaa = pathfn('a/aa/aaa/')
722 bb = pathfn('a/bb')
723 c = pathfn('c.txt')
724 zzz = pathfn('zzz')
725
726 fs.create_dir(aaa)
727 with fs.open_output_stream(bb):
728 pass # touch
729 with fs.open_output_stream(c) as fp:
730 fp.write(b'test')
731
732 aaa_info, bb_info, c_info, zzz_info = fs.get_file_info([aaa, bb, c, zzz])
733
734 assert aaa_info.path == aaa
735 assert 'aaa' in repr(aaa_info)
736 assert aaa_info.extension == ''
737 if fs.type_name == "py::fsspec+('s3', 's3a')":
738 # s3fs doesn't create empty directories
739 assert aaa_info.type == FileType.NotFound
740 else:
741 assert aaa_info.type == FileType.Directory
742 assert 'FileType.Directory' in repr(aaa_info)
743 assert aaa_info.size is None
744 check_mtime_or_absent(aaa_info)
745
746 assert bb_info.path == str(bb)
747 assert bb_info.base_name == 'bb'
748 assert bb_info.extension == ''
749 assert bb_info.type == FileType.File
750 assert 'FileType.File' in repr(bb_info)
751 assert bb_info.size == 0
752 if fs.type_name not in ["py::fsspec+memory", "py::fsspec+('s3', 's3a')"]:
753 check_mtime(bb_info)
754
755 assert c_info.path == str(c)
756 assert c_info.base_name == 'c.txt'
757 assert c_info.extension == 'txt'
758 assert c_info.type == FileType.File
759 assert 'FileType.File' in repr(c_info)
760 assert c_info.size == 4
761 if fs.type_name not in ["py::fsspec+memory", "py::fsspec+('s3', 's3a')"]:
762 check_mtime(c_info)
763
764 assert zzz_info.path == str(zzz)
765 assert zzz_info.base_name == 'zzz'
766 assert zzz_info.extension == ''
767 assert zzz_info.type == FileType.NotFound
768 assert zzz_info.size is None
769 assert zzz_info.mtime is None
770 assert 'FileType.NotFound' in repr(zzz_info)
771 check_mtime_absent(zzz_info)
772
773 # with single path
774 aaa_info2 = fs.get_file_info(aaa)
775 assert aaa_info.path == aaa_info2.path
776 assert aaa_info.type == aaa_info2.type
777

Callers

nothing calls this directly

Calls 8

pathfnFunction · 0.85
check_mtime_or_absentFunction · 0.85
check_mtimeFunction · 0.85
check_mtime_absentFunction · 0.85
create_dirMethod · 0.45
open_output_streamMethod · 0.45
writeMethod · 0.45
get_file_infoMethod · 0.45

Tested by

no test coverage detected