From 55cbe177acc8dc66f766d04b128f7b0f7f6beefa Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Fri, 9 Feb 2024 12:58:46 +0100 Subject: [PATCH] test: fix stalling future --- tests/async/test_unroute_behavior.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/async/test_unroute_behavior.py b/tests/async/test_unroute_behavior.py index 8a9b46b3b..036423cdc 100644 --- a/tests/async/test_unroute_behavior.py +++ b/tests/async/test_unroute_behavior.py @@ -351,6 +351,7 @@ async def _unroute_promise() -> None: async def test_page_close_does_not_wait_for_active_route_handlers( page: Page, server: Server ) -> None: + stalling_future: "asyncio.Future[None]" = asyncio.Future() second_handler_called = False def _handler1(route: Route) -> None: @@ -365,7 +366,7 @@ def _handler1(route: Route) -> None: async def _handler2(route: Route) -> None: route_future.set_result(route) - await asyncio.Future() + await stalling_future await page.route( "**/*", @@ -383,6 +384,7 @@ async def _goto_ignore_exceptions() -> None: await page.close() await asyncio.sleep(0.5) assert not second_handler_called + stalling_future.cancel() async def test_route_continue_should_not_throw_if_page_has_been_closed(