File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed
Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -12,12 +12,21 @@ def test_list_files(self):
1212 filepath_list = list_files (directory , contains = ["json" ], verbose = False )
1313 assert len (filepath_list ) == 11
1414
15- def test_list_files_recursively (self ):
15+ def test_list_files_recursively (self , tmp_path ):
16+ import shutil
17+ from pathlib import Path
18+
1619 from sahi .utils .file import list_files_recursively
1720
18- directory = "tests/data/coco_utils/"
21+ # Copy only the target json files into an isolated temp directory to avoid race
22+ # with other tests that may create additional *coco.json files recursively.
23+ src_dir = Path ("tests/data/coco_utils/" )
24+ for f in src_dir .iterdir ():
25+ if f .is_file () and "coco.json" in f .name :
26+ shutil .copy (f , tmp_path / f .name )
27+
1928 relative_filepath_list , abs_filepath_list = list_files_recursively (
20- directory , contains = ["coco.json" ], verbose = False
29+ str ( tmp_path ) , contains = ["coco.json" ], verbose = False
2130 )
2231 assert len (relative_filepath_list ) == 7
2332 assert len (abs_filepath_list ) == 7
You can’t perform that action at this time.
0 commit comments