Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion playwright/_impl/_artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ async def save_as(self, path: Union[str, Path]) -> None:
await stream.save_as(path)

async def failure(self) -> Optional[str]:
return patch_error_message(await self._channel.send("failure"))
reason = await self._channel.send("failure")
if reason is None:
return None
return patch_error_message(reason)

async def delete(self) -> None:
await self._channel.send("delete")
Expand Down
2 changes: 1 addition & 1 deletion playwright/_impl/_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def patch_error_message(message: str) -> str:
if match:
message = to_snake_case(match.group(1)) + match.group(2)
message = message.replace(
"Pass { acceptDownloads: true }", "Pass { accept_downloads: True }"
"Pass { acceptDownloads: true }", "Pass 'accept_downloads=True'"
)
return message

Expand Down
7 changes: 6 additions & 1 deletion tests/async/test_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ async def test_should_report_downloads_with_accept_downloads_false(
== f"<Download url={download.url!r} suggested_filename={download.suggested_filename!r}>"
)
assert await download.path()
assert await download.failure() is None


async def test_should_report_downloads_with_accept_downloads_true(
Expand Down Expand Up @@ -180,9 +181,13 @@ async def test_should_error_when_saving_with_downloads_disabled(
with pytest.raises(Error) as exc:
await download.save_as(user_path)
assert (
"Pass { accept_downloads: True } when you are creating your browser context"
"Pass 'accept_downloads=True' when you are creating your browser context"
in exc.value.message
)
assert (
"Pass 'accept_downloads=True' when you are creating your browser context."
== await download.failure()
)
await page.close()


Expand Down