File tree Expand file tree Collapse file tree 1 file changed +3
-11
lines changed
Expand file tree Collapse file tree 1 file changed +3
-11
lines changed Original file line number Diff line number Diff line change 11# Consider factoring this out of the test file
22import os
3+ import shutil
34import tempfile
4- import zipfile
55from pathlib import Path
66
77
@@ -15,18 +15,10 @@ def pytest_generate_tests(metafunc):
1515 metafunc .parametrize ("broken_model_path" , model_paths )
1616
1717
18- def zipdir (path , ziph ):
19- # ziph is zipfile handle
20- for root , dirs , files in os .walk (path ):
21- for file in files :
22- ziph .write (os .path .join (root , file ))
23-
24-
2518def create_zip (model_dir ):
2619 osw_dir_path = os .path .join (os .path .dirname (__file__ ), 'models' , model_dir )
2720 zip_file_fd , zip_file_path = tempfile .mkstemp (suffix = '.zip' )
21+ zip_file_path = Path (zip_file_path )
22+ shutil .make_archive (zip_file_path .parent / zip_file_path .stem , "zip" , osw_dir_path )
2823
29- zipf = zipfile .ZipFile (zip_file_path , 'w' , zipfile .ZIP_DEFLATED )
30- zipdir (osw_dir_path , zipf )
31- zipf .close ()
3224 return zip_file_path
You can’t perform that action at this time.
0 commit comments