Skip to content

Commit

Permalink
Test failure on 204 status
Browse files Browse the repository at this point in the history
  • Loading branch information
elacuesta committed Jul 6, 2024
1 parent 06ab0b6 commit d0b2291
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/mockserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ def do_GET(self) -> None:

if parsed_path.path == "/headers":
self._send_json(dict(self.headers))
elif parsed_path.path == "/status/204":
self.send_response(204)
self.end_headers()
elif parsed_path.path == "/redirect2":
self.send_response(302)
self.send_header("Content-Length", "0")
Expand Down
17 changes: 17 additions & 0 deletions tests/tests_asyncio/test_playwright_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,23 @@ async def cancel_download(download):
f" exc_type={type(excinfo.value)} exc_msg={str(excinfo.value)}",
) in self._caplog.record_tuples

@allow_windows
async def test_fail_status_204(self):
async with make_handler({"PLAYWRIGHT_BROWSER_TYPE": self.browser_type}) as handler:
with MockServer() as server:
request = Request(
url=server.urljoin("/status/204"),
meta={"playwright": True},
)
with pytest.raises(PlaywrightError) as excinfo:
await handler._download_request(request, Spider("foo"))
assert (
"scrapy-playwright",
logging.WARNING,
f"Closing page due to failed request: {request}"
f" exc_type={type(excinfo.value)} exc_msg={str(excinfo.value)}",
) in self._caplog.record_tuples


class TestCaseChromium(IsolatedAsyncioTestCase, MixinTestCase):
browser_type = "chromium"
Expand Down

0 comments on commit d0b2291

Please sign in to comment.