@@ -318,15 +318,14 @@ def test_update_tags(server: TSC.Server) -> None:
318318 assert single_workbook ._initial_tags == updated_workbook ._initial_tags
319319
320320
321- def test_download (server : TSC .Server ) -> None :
321+ def test_download (server : TSC .Server , tmp_path : Path ) -> None :
322322 with requests_mock .mock () as m :
323323 m .get (
324324 server .workbooks .baseurl + "/1f951daf-4061-451a-9df1-69a8062664f2/content" ,
325325 headers = {"Content-Disposition" : 'name="tableau_workbook"; filename="RESTAPISample.twbx"' },
326326 )
327- file_path = server .workbooks .download ("1f951daf-4061-451a-9df1-69a8062664f2" )
327+ file_path = server .workbooks .download ("1f951daf-4061-451a-9df1-69a8062664f2" , filepath = tmp_path )
328328 assert os .path .exists (file_path )
329- os .remove (file_path )
330329
331330
332331def test_download_object (server : TSC .Server ) -> None :
@@ -340,21 +339,20 @@ def test_download_object(server: TSC.Server) -> None:
340339 assert isinstance (file_path , BytesIO )
341340
342341
343- def test_download_sanitizes_name (server : TSC .Server ) -> None :
342+ def test_download_sanitizes_name (server : TSC .Server , tmp_path : Path ) -> None :
344343 filename = "Name,With,Commas.twbx"
345344 disposition = f'name="tableau_workbook"; filename="{ filename } "'
346345 with requests_mock .mock () as m :
347346 m .get (
348347 server .workbooks .baseurl + "/1f951daf-4061-451a-9df1-69a8062664f2/content" ,
349348 headers = {"Content-Disposition" : disposition },
350349 )
351- file_path = server .workbooks .download ("1f951daf-4061-451a-9df1-69a8062664f2" )
350+ file_path = server .workbooks .download ("1f951daf-4061-451a-9df1-69a8062664f2" , filepath = tmp_path )
352351 assert os .path .basename (file_path ) == "NameWithCommas.twbx"
353352 assert os .path .exists (file_path )
354- os .remove (file_path )
355353
356354
357- def test_download_extract_only (server : TSC .Server ) -> None :
355+ def test_download_extract_only (server : TSC .Server , tmp_path : Path ) -> None :
358356 # Pretend we're 2.5 for 'extract_only'
359357 server .version = "2.5"
360358
@@ -365,12 +363,13 @@ def test_download_extract_only(server: TSC.Server) -> None:
365363 complete_qs = True ,
366364 )
367365 # Technically this shouldn't download a twbx, but we are interested in the qs, not the file
368- file_path = server .workbooks .download ("1f951daf-4061-451a-9df1-69a8062664f2" , include_extract = False )
366+ file_path = server .workbooks .download (
367+ "1f951daf-4061-451a-9df1-69a8062664f2" , include_extract = False , filepath = tmp_path
368+ )
369369 assert os .path .exists (file_path )
370- os .remove (file_path )
371370
372371
373- def test_download_no_extract_emits_deprecation_warning (server : TSC .Server ) -> None :
372+ def test_download_no_extract_emits_deprecation_warning (server : TSC .Server , tmp_path : Path ) -> None :
374373 """no_extract=True should emit a DeprecationWarning and map to includeExtract=False."""
375374 server .version = "2.5"
376375
@@ -381,9 +380,10 @@ def test_download_no_extract_emits_deprecation_warning(server: TSC.Server) -> No
381380 complete_qs = True ,
382381 )
383382 with pytest .warns (DeprecationWarning , match = "deprecated and will be removed" ):
384- file_path = server .workbooks .download ("1f951daf-4061-451a-9df1-69a8062664f2" , no_extract = True )
383+ file_path = server .workbooks .download (
384+ "1f951daf-4061-451a-9df1-69a8062664f2" , no_extract = True , filepath = tmp_path
385+ )
385386 assert os .path .exists (file_path )
386- os .remove (file_path )
387387
388388
389389def test_download_missing_id (server : TSC .Server ) -> None :
0 commit comments