|
| 1 | +# Copyright (c) Microsoft Corporation. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +import pytest |
| 16 | + |
| 17 | +from playwright.sync_api import BrowserContext, Error, Page |
| 18 | +from tests.server import Server |
| 19 | + |
| 20 | + |
| 21 | +def test_context_request_should_support_timeout_option( |
| 22 | + page: Page, context: BrowserContext, server: Server |
| 23 | +) -> None: |
| 24 | + # https://github.com/microsoft/playwright/issues/39220 |
| 25 | + |
| 26 | + server.set_route("/", lambda req: None) |
| 27 | + with pytest.raises(Error, match="Timeout 123ms exceeded"): |
| 28 | + page.request.get(server.PREFIX, timeout=123) |
| 29 | + with pytest.raises(Error, match="Timeout 123ms exceeded"): |
| 30 | + context.request.get(server.PREFIX, timeout=123) |
| 31 | + |
| 32 | + context.set_default_timeout(123) |
| 33 | + with pytest.raises(Error, match="Timeout 123ms exceeded"): |
| 34 | + page.request.get(server.PREFIX) |
| 35 | + with pytest.raises(Error, match="Timeout 123ms exceeded"): |
| 36 | + context.request.get(server.PREFIX) |
0 commit comments