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

Function test_fsspec_delete_root_dir_contents

python/pyarrow/tests/test_fs.py:2240–2272  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2238
2239
2240def test_fsspec_delete_root_dir_contents():
2241 try:
2242 from fsspec.implementations.memory import MemoryFileSystem
2243 except ImportError:
2244 pytest.skip("fsspec not installed")
2245
2246 fs = FSSpecHandler(MemoryFileSystem())
2247
2248 # Create some files and directories
2249 fs.create_dir("test_dir", recursive=True)
2250 fs.create_dir("test_dir/subdir", recursive=True)
2251
2252 with fs.open_output_stream("test_file.txt", metadata={}) as stream:
2253 stream.write(b"test content")
2254
2255 with fs.open_output_stream("test_dir/nested_file.txt", metadata={}) as stream:
2256 stream.write(b"nested content")
2257
2258 # Verify files exist before deletion
2259 def get_type(path):
2260 return fs.get_file_info([path])[0].type
2261
2262 assert get_type("test_file.txt") == FileType.File
2263 assert get_type("test_dir") == FileType.Directory
2264 assert get_type("test_dir/nested_file.txt") == FileType.File
2265
2266 # Delete root directory contents
2267 fs.delete_root_dir_contents()
2268
2269 # Assert all files and directories are deleted
2270 assert get_type("test_file.txt") == FileType.NotFound
2271 assert get_type("test_dir") == FileType.NotFound
2272 assert get_type("test_dir/nested_file.txt") == FileType.NotFound
2273
2274
2275def test_huggingface_filesystem_from_uri():

Callers

nothing calls this directly

Calls 6

create_dirMethod · 0.95
open_output_streamMethod · 0.95
FSSpecHandlerClass · 0.90
get_typeFunction · 0.85
writeMethod · 0.45

Tested by

no test coverage detected