From eab76fd32a9afb32b3690174282edeff2c642caf Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Thu, 12 Oct 2023 09:01:31 +0200 Subject: [PATCH] test: unflake test_page_route_should_work_with_redirects_for_subresources --- tests/async/test_interception.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/tests/async/test_interception.py b/tests/async/test_interception.py index 08a24273a..e71c7bffe 100644 --- a/tests/async/test_interception.py +++ b/tests/async/test_interception.py @@ -328,13 +328,12 @@ async def test_page_route_should_not_work_with_redirects(page, server): async def test_page_route_should_work_with_redirects_for_subresources(page, server): intercepted = [] - await page.route( - "**/*", - lambda route: ( - asyncio.create_task(route.continue_()), - intercepted.append(route.request), - ), - ) + + async def handle_route(route) -> None: + await route.continue_() + intercepted.append(route.request) + + await page.route("**/*", handle_route) server.set_redirect("/one-style.css", "/two-style.css") server.set_redirect("/two-style.css", "/three-style.css") @@ -348,8 +347,7 @@ async def test_page_route_should_work_with_redirects_for_subresources(page, serv assert response.status == 200 assert "one-style.html" in response.url - # TODO: https://github.com/microsoft/playwright/issues/12789 - assert len(intercepted) >= 2 + assert len(intercepted) == 2 assert intercepted[0].resource_type == "document" assert "one-style.html" in intercepted[0].url