@@ -84,6 +84,29 @@ def test_cached_path_extract(xz_file, tmp_path, text_file):
8484 assert extracted_file_content == expected_file_content
8585
8686
87+ @pytest .mark .parametrize ("default_extracted" , [True , False ])
88+ @pytest .mark .parametrize ("default_cache_dir" , [True , False ])
89+ def test_extracted_datasets_path (default_extracted , default_cache_dir , xz_file , tmp_path , monkeypatch ):
90+ custom_cache_dir = "custom_cache"
91+ custom_extracted_dir = "custom_extracted_dir"
92+ custom_extracted_path = tmp_path / "custom_extracted_path"
93+ if default_extracted :
94+ expected = ("downloads" if default_cache_dir else custom_cache_dir , "extracted" )
95+ else :
96+ monkeypatch .setattr ("datasets.config.EXTRACTED_DATASETS_DIR" , custom_extracted_dir )
97+ monkeypatch .setattr ("datasets.config.EXTRACTED_DATASETS_PATH" , str (custom_extracted_path ))
98+ expected = custom_extracted_path .parts [- 2 :] if default_cache_dir else (custom_cache_dir , custom_extracted_dir )
99+
100+ filename = xz_file
101+ download_config = (
102+ DownloadConfig (extract_compressed_file = True )
103+ if default_cache_dir
104+ else DownloadConfig (cache_dir = tmp_path / custom_cache_dir , extract_compressed_file = True )
105+ )
106+ extracted_file_path = cached_path (filename , download_config = download_config )
107+ assert Path (extracted_file_path ).parent .parts [- 2 :] == expected
108+
109+
87110def test_cached_path_local (text_file ):
88111 # absolute path
89112 text_file = str (Path (text_file ).resolve ())
0 commit comments