diff --git a/playwright/_impl/_fetch.py b/playwright/_impl/_fetch.py index e4174ea27..50bf4ad4a 100644 --- a/playwright/_impl/_fetch.py +++ b/playwright/_impl/_fetch.py @@ -412,6 +412,7 @@ async def _inner_fetch( self._timeout_settings.timeout, { "url": url, + "timeout": timeout, "params": object_to_array(params) if isinstance(params, dict) else None, "encodedParams": params if isinstance(params, str) else None, "method": method, diff --git a/tests/async/test_fetch_global.py b/tests/async/test_fetch_global.py index e2a7678c5..1f7593194 100644 --- a/tests/async/test_fetch_global.py +++ b/tests/async/test_fetch_global.py @@ -89,6 +89,15 @@ async def test_should_support_global_timeout_option( await request.get(server.EMPTY_PAGE) +async def test_should_support_timeout_option_in_get_method( + playwright: Playwright, server: Server +) -> None: + request = await playwright.request.new_context() + server.set_route("/empty.html", lambda req: None) + with pytest.raises(Error, match="APIRequestContext.get: Timeout 123ms exceeded."): + await request.get(server.EMPTY_PAGE, timeout=123) + + async def test_should_propagate_extra_http_headers_with_redirects( playwright: Playwright, server: Server ) -> None: diff --git a/tests/async/test_page_request_intercept.py b/tests/async/test_page_request_intercept.py index dc8f7416a..a9859e87b 100644 --- a/tests/async/test_page_request_intercept.py +++ b/tests/async/test_page_request_intercept.py @@ -34,7 +34,7 @@ def _handler(request: TestServerRequest) -> None: async def handle(route: Route) -> None: with pytest.raises(Error) as error: await route.fetch(timeout=1000) - assert "Timeout 1000ms exceeded" in error.value.message + assert "Route.fetch: Timeout 1000ms exceeded." in error.value.message await page.route("**/*", lambda route: handle(route)) with pytest.raises(Error) as error: diff --git a/tests/sync/test_fetch_global.py b/tests/sync/test_fetch_global.py index bf3970c21..5cb3abc5b 100644 --- a/tests/sync/test_fetch_global.py +++ b/tests/sync/test_fetch_global.py @@ -71,6 +71,15 @@ def test_should_support_global_timeout_option( request.get(server.EMPTY_PAGE) +def test_should_support_timeout_option_in_get_method( + playwright: Playwright, server: Server +) -> None: + request = playwright.request.new_context() + server.set_route("/empty.html", lambda req: None) + with pytest.raises(Error, match="APIRequestContext.get: Timeout 123ms exceeded."): + request.get(server.EMPTY_PAGE, timeout=123) + + def test_should_propagate_extra_http_headers_with_redirects( playwright: Playwright, server: Server ) -> None: diff --git a/tests/sync/test_page_request_intercept.py b/tests/sync/test_page_request_intercept.py index 86cf21b63..1d3dd0f46 100644 --- a/tests/sync/test_page_request_intercept.py +++ b/tests/sync/test_page_request_intercept.py @@ -34,7 +34,7 @@ def _handle(request: TestServerRequest) -> None: def handle(route: Route) -> None: with pytest.raises(Error) as error: route.fetch(timeout=1000) - assert "Request timed out after 1000ms" in error.value.message + assert "Route.fetch: Timeout 1000ms exceeded." in error.value.message page.route("**/*", lambda route: handle(route)) with pytest.raises(Error) as error: