@@ -460,31 +460,27 @@ def test_download_project(
460460 project_version = diff_project .get_latest_version ()
461461 if zipfile :
462462 zip_path = Path (project_version .zip_path )
463+ if zip_path .parent .exists ():
464+ shutil .rmtree (zip_path .parent , ignore_errors = True )
463465 zip_path .parent .mkdir (parents = True , exist_ok = True )
464466 zip_path .touch ()
465467 if partial :
466468 temp_zip_path = Path (project_version .zip_path + ".partial" )
469+ shutil .rmtree (temp_zip_path .parent , ignore_errors = True )
467470 temp_zip_path .parent .mkdir (parents = True , exist_ok = True )
468471 temp_zip_path .touch ()
469472 if expired :
470473 new_time = datetime .now () - timedelta (
471474 seconds = current_app .config ["PARTIAL_ZIP_EXPIRATION" ] + 1
472475 )
473476 modify_file_times (temp_zip_path , new_time )
474- try :
475- resp = client .get (
476- url_for (
477- "/app.mergin_sync_private_api_controller_download_project" ,
478- id = diff_project .id ,
479- version = version if version else "" ,
480- )
477+ resp = client .get (
478+ url_for (
479+ "/app.mergin_sync_private_api_controller_download_project" ,
480+ id = diff_project .id ,
481+ version = version if version else "" ,
481482 )
482- finally :
483- # cleanup
484- if zipfile :
485- shutil .rmtree (zip_path .parent , ignore_errors = True )
486- if partial :
487- shutil .rmtree (temp_zip_path .parent , ignore_errors = True )
483+ )
488484 assert resp .status_code == exp_resp
489485 assert mock_create_zip .called == exp_call
490486 if not version and exp_call :
0 commit comments