MCPcopy
hub / github.com/huggingface/datasets / test_compression_filesystems

Function test_compression_filesystems

tests/test_filesystem.py:34–49  ·  view source on GitHub ↗
(compression_fs_class, gz_file, bz2_file, lz4_file, zstd_file, xz_file, text_file)

Source from the content-addressed store, hash-verified

32
33@pytest.mark.parametrize("compression_fs_class", COMPRESSION_FILESYSTEMS)
34def test_compression_filesystems(compression_fs_class, gz_file, bz2_file, lz4_file, zstd_file, xz_file, text_file):
35 input_paths = {"gzip": gz_file, "xz": xz_file, "zstd": zstd_file, "bz2": bz2_file, "lz4": lz4_file}
36 input_path = input_paths[compression_fs_class.protocol]
37 if input_path is None:
38 reason = f"for '{compression_fs_class.protocol}' compression protocol, "
39 if compression_fs_class.protocol == "lz4":
40 reason += require_lz4.kwargs["reason"]
41 elif compression_fs_class.protocol == "zstd":
42 reason += require_zstandard.kwargs["reason"]
43 pytest.skip(reason)
44 fs = fsspec.filesystem(compression_fs_class.protocol, fo=input_path)
45 expected_filename = os.path.basename(input_path)
46 expected_filename = expected_filename[: expected_filename.rindex(".")]
47 assert fs.glob("*") == [expected_filename]
48 with fs.open(expected_filename, "r", encoding="utf-8") as f, open(text_file, encoding="utf-8") as expected_file:
49 assert f.read() == expected_file.read()
50
51
52@pytest.mark.parametrize("protocol", ["zip", "gzip"])

Callers

nothing calls this directly

Calls 4

globMethod · 0.80
openMethod · 0.80
skipMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected