()
| 2238 | |
| 2239 | |
| 2240 | def 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 | |
| 2275 | def test_huggingface_filesystem_from_uri(): |
nothing calls this directly
no test coverage detected