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

Function test_from_dir

tests/test_info.py:20–34  ·  view source on GitHub ↗
(files, tmp_path_factory)

Source from the content-addressed store, hash-verified

18 ],
19)
20def test_from_dir(files, tmp_path_factory):
21 dataset_infos_dir = tmp_path_factory.mktemp("dset_infos_dir")
22 if "full:README.md" in files:
23 with open(dataset_infos_dir / "README.md", "w") as f:
24 f.write("---\ndataset_info:\n dataset_size: 42\n---")
25 if "empty:README.md" in files:
26 with open(dataset_infos_dir / "README.md", "w") as f:
27 f.write("")
28 # we want to support dataset_infos.json for backward compatibility
29 if "dataset_infos.json" in files:
30 with open(dataset_infos_dir / "dataset_infos.json", "w") as f:
31 f.write('{"default": {"dataset_size": 42}}')
32 dataset_infos = DatasetInfosDict.from_directory(dataset_infos_dir)
33 assert dataset_infos
34 assert dataset_infos["default"].dataset_size == 42
35
36
37@pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 2

writeMethod · 0.45
from_directoryMethod · 0.45

Tested by

no test coverage detected