@@ -83,29 +83,29 @@ async def test_should_report_downloads_with_accept_downloads_true(
83
83
84
84
85
85
async def test_should_save_to_user_specified_path (
86
- tmpdir : Path , browser : Browser , server : Server
86
+ tmp_path : Path , browser : Browser , server : Server
87
87
) -> None :
88
88
page = await browser .new_page (accept_downloads = True )
89
89
await page .set_content (f'<a href="{ server .PREFIX } /download">download</a>' )
90
90
async with page .expect_download () as download_info :
91
91
await page .click ("a" )
92
92
download = await download_info .value
93
- user_path = tmpdir / "download.txt"
93
+ user_path = tmp_path / "download.txt"
94
94
await download .save_as (user_path )
95
95
assert user_path .exists ()
96
96
assert user_path .read_text ("utf-8" ) == "Hello world"
97
97
await page .close ()
98
98
99
99
100
100
async 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
102
102
) -> None :
103
103
page = await browser .new_page (accept_downloads = True )
104
104
await page .set_content (f'<a href="{ server .PREFIX } /download">download</a>' )
105
105
async with page .expect_download () as download_info :
106
106
await page .click ("a" )
107
107
download = await download_info .value
108
- user_path = tmpdir / "download.txt"
108
+ user_path = tmp_path / "download.txt"
109
109
await download .save_as (user_path )
110
110
assert user_path .exists ()
111
111
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
117
117
118
118
119
119
async 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
121
121
) -> None :
122
122
page = await browser .new_page (accept_downloads = True )
123
123
await page .set_content (f'<a href="{ server .PREFIX } /download">download</a>' )
124
124
async with page .expect_download () as download_info :
125
125
await page .click ("a" )
126
126
download = await download_info .value
127
- user_path = tmpdir / "download.txt"
127
+ user_path = tmp_path / "download.txt"
128
128
await download .save_as (user_path )
129
129
assert user_path .exists ()
130
130
assert user_path .read_text ("utf-8" ) == "Hello world"
131
131
132
- anotheruser_path = tmpdir / "download (2).txt"
132
+ anotheruser_path = tmp_path / "download (2).txt"
133
133
await download .save_as (anotheruser_path )
134
134
assert anotheruser_path .exists ()
135
135
assert anotheruser_path .read_text ("utf-8" ) == "Hello world"
136
136
await page .close ()
137
137
138
138
139
139
async def test_should_save_to_overwritten_filepath (
140
- tmpdir : Path , browser : Browser , server : Server
140
+ tmp_path : Path , browser : Browser , server : Server
141
141
) -> None :
142
142
page = await browser .new_page (accept_downloads = True )
143
143
await page .set_content (f'<a href="{ server .PREFIX } /download">download</a>' )
144
144
async with page .expect_download () as download_info :
145
145
await page .click ("a" )
146
146
download = await download_info .value
147
- user_path = tmpdir / "download.txt"
147
+ user_path = tmp_path / "download.txt"
148
148
await download .save_as (user_path )
149
- assert len (list (Path ( tmpdir ) .glob ("*.*" ))) == 1
149
+ assert len (list (tmp_path .glob ("*.*" ))) == 1
150
150
await download .save_as (user_path )
151
- assert len (list (Path ( tmpdir ) .glob ("*.*" ))) == 1
151
+ assert len (list (tmp_path .glob ("*.*" ))) == 1
152
152
assert user_path .exists ()
153
153
assert user_path .read_text ("utf-8" ) == "Hello world"
154
154
await page .close ()
155
155
156
156
157
157
async 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
159
159
) -> None :
160
160
page = await browser .new_page (accept_downloads = True )
161
161
await page .set_content (f'<a href="{ server .PREFIX } /download">download</a>' )
162
162
async with page .expect_download () as download_info :
163
163
await page .click ("a" )
164
164
download = await download_info .value
165
- nested_path = tmpdir / "these" / "are" / "directories" / "download.txt"
165
+ nested_path = tmp_path / "these" / "are" / "directories" / "download.txt"
166
166
await download .save_as (nested_path )
167
167
assert nested_path .exists ()
168
168
assert nested_path .read_text ("utf-8" ) == "Hello world"
169
169
await page .close ()
170
170
171
171
172
172
async def test_should_error_when_saving_with_downloads_disabled (
173
- tmpdir : Path , browser : Browser , server : Server
173
+ tmp_path : Path , browser : Browser , server : Server
174
174
) -> None :
175
175
page = await browser .new_page (accept_downloads = False )
176
176
await page .set_content (f'<a href="{ server .PREFIX } /download">download</a>' )
177
177
async with page .expect_download () as download_info :
178
178
await page .click ("a" )
179
179
download = await download_info .value
180
- user_path = tmpdir / "download.txt"
180
+ user_path = tmp_path / "download.txt"
181
181
with pytest .raises (Error ) as exc :
182
182
await download .save_as (user_path )
183
183
assert (
@@ -192,14 +192,14 @@ async def test_should_error_when_saving_with_downloads_disabled(
192
192
193
193
194
194
async def test_should_error_when_saving_after_deletion (
195
- tmpdir : Path , browser : Browser , server : Server
195
+ tmp_path : Path , browser : Browser , server : Server
196
196
) -> None :
197
197
page = await browser .new_page (accept_downloads = True )
198
198
await page .set_content (f'<a href="{ server .PREFIX } /download">download</a>' )
199
199
async with page .expect_download () as download_info :
200
200
await page .click ("a" )
201
201
download = await download_info .value
202
- user_path = tmpdir / "download.txt"
202
+ user_path = tmp_path / "download.txt"
203
203
await download .delete ()
204
204
with pytest .raises (Error ) as exc :
205
205
await download .save_as (user_path )
0 commit comments