@@ -83,29 +83,29 @@ async def test_should_report_downloads_with_accept_downloads_true(
8383
8484
8585async def test_should_save_to_user_specified_path (
86- tmpdir : Path , browser : Browser , server : Server
86+ tmp_path : Path , browser : Browser , server : Server
8787) -> None :
8888 page = await browser .new_page (accept_downloads = True )
8989 await page .set_content (f'<a href="{ server .PREFIX } /download">download</a>' )
9090 async with page .expect_download () as download_info :
9191 await page .click ("a" )
9292 download = await download_info .value
93- user_path = tmpdir / "download.txt"
93+ user_path = tmp_path / "download.txt"
9494 await download .save_as (user_path )
9595 assert user_path .exists ()
9696 assert user_path .read_text ("utf-8" ) == "Hello world"
9797 await page .close ()
9898
9999
100100async def test_should_save_to_user_specified_path_without_updating_original_path (
101- tmpdir : Path , browser : Browser , server : Server
101+ tmp_path : Path , browser : Browser , server : Server
102102) -> None :
103103 page = await browser .new_page (accept_downloads = True )
104104 await page .set_content (f'<a href="{ server .PREFIX } /download">download</a>' )
105105 async with page .expect_download () as download_info :
106106 await page .click ("a" )
107107 download = await download_info .value
108- user_path = tmpdir / "download.txt"
108+ user_path = tmp_path / "download.txt"
109109 await download .save_as (user_path )
110110 assert user_path .exists ()
111111 assert user_path .read_text ("utf-8" ) == "Hello world"
@@ -117,67 +117,67 @@ async def test_should_save_to_user_specified_path_without_updating_original_path
117117
118118
119119async def test_should_save_to_two_different_paths_with_multiple_save_as_calls (
120- tmpdir : Path , browser : Browser , server : Server
120+ tmp_path : Path , browser : Browser , server : Server
121121) -> None :
122122 page = await browser .new_page (accept_downloads = True )
123123 await page .set_content (f'<a href="{ server .PREFIX } /download">download</a>' )
124124 async with page .expect_download () as download_info :
125125 await page .click ("a" )
126126 download = await download_info .value
127- user_path = tmpdir / "download.txt"
127+ user_path = tmp_path / "download.txt"
128128 await download .save_as (user_path )
129129 assert user_path .exists ()
130130 assert user_path .read_text ("utf-8" ) == "Hello world"
131131
132- anotheruser_path = tmpdir / "download (2).txt"
132+ anotheruser_path = tmp_path / "download (2).txt"
133133 await download .save_as (anotheruser_path )
134134 assert anotheruser_path .exists ()
135135 assert anotheruser_path .read_text ("utf-8" ) == "Hello world"
136136 await page .close ()
137137
138138
139139async def test_should_save_to_overwritten_filepath (
140- tmpdir : Path , browser : Browser , server : Server
140+ tmp_path : Path , browser : Browser , server : Server
141141) -> None :
142142 page = await browser .new_page (accept_downloads = True )
143143 await page .set_content (f'<a href="{ server .PREFIX } /download">download</a>' )
144144 async with page .expect_download () as download_info :
145145 await page .click ("a" )
146146 download = await download_info .value
147- user_path = tmpdir / "download.txt"
147+ user_path = tmp_path / "download.txt"
148148 await download .save_as (user_path )
149- assert len (list (Path ( tmpdir ) .glob ("*.*" ))) == 1
149+ assert len (list (tmp_path .glob ("*.*" ))) == 1
150150 await download .save_as (user_path )
151- assert len (list (Path ( tmpdir ) .glob ("*.*" ))) == 1
151+ assert len (list (tmp_path .glob ("*.*" ))) == 1
152152 assert user_path .exists ()
153153 assert user_path .read_text ("utf-8" ) == "Hello world"
154154 await page .close ()
155155
156156
157157async def test_should_create_subdirectories_when_saving_to_non_existent_user_specified_path (
158- tmpdir : Path , browser : Browser , server : Server
158+ tmp_path : Path , browser : Browser , server : Server
159159) -> None :
160160 page = await browser .new_page (accept_downloads = True )
161161 await page .set_content (f'<a href="{ server .PREFIX } /download">download</a>' )
162162 async with page .expect_download () as download_info :
163163 await page .click ("a" )
164164 download = await download_info .value
165- nested_path = tmpdir / "these" / "are" / "directories" / "download.txt"
165+ nested_path = tmp_path / "these" / "are" / "directories" / "download.txt"
166166 await download .save_as (nested_path )
167167 assert nested_path .exists ()
168168 assert nested_path .read_text ("utf-8" ) == "Hello world"
169169 await page .close ()
170170
171171
172172async def test_should_error_when_saving_with_downloads_disabled (
173- tmpdir : Path , browser : Browser , server : Server
173+ tmp_path : Path , browser : Browser , server : Server
174174) -> None :
175175 page = await browser .new_page (accept_downloads = False )
176176 await page .set_content (f'<a href="{ server .PREFIX } /download">download</a>' )
177177 async with page .expect_download () as download_info :
178178 await page .click ("a" )
179179 download = await download_info .value
180- user_path = tmpdir / "download.txt"
180+ user_path = tmp_path / "download.txt"
181181 with pytest .raises (Error ) as exc :
182182 await download .save_as (user_path )
183183 assert (
@@ -192,14 +192,14 @@ async def test_should_error_when_saving_with_downloads_disabled(
192192
193193
194194async def test_should_error_when_saving_after_deletion (
195- tmpdir : Path , browser : Browser , server : Server
195+ tmp_path : Path , browser : Browser , server : Server
196196) -> None :
197197 page = await browser .new_page (accept_downloads = True )
198198 await page .set_content (f'<a href="{ server .PREFIX } /download">download</a>' )
199199 async with page .expect_download () as download_info :
200200 await page .click ("a" )
201201 download = await download_info .value
202- user_path = tmpdir / "download.txt"
202+ user_path = tmp_path / "download.txt"
203203 await download .delete ()
204204 with pytest .raises (Error ) as exc :
205205 await download .save_as (user_path )
0 commit comments