From d5838a39da8c80d725c78283749c2772dbb92a35 Mon Sep 17 00:00:00 2001 From: David Foster Date: Tue, 9 Jan 2024 09:28:53 -0500 Subject: [PATCH] Tests: test_addgroup: Fix soft timeout warnings to point to test code rather than to infrastructure --- src/crystal/tests/test_addgroup.py | 8 ++++++-- src/crystal/tests/util/wait.py | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/crystal/tests/test_addgroup.py b/src/crystal/tests/test_addgroup.py index f4f24df0..821d3db4 100644 --- a/src/crystal/tests/test_addgroup.py +++ b/src/crystal/tests/test_addgroup.py @@ -400,8 +400,12 @@ async def _expand_node(node_ti: TreeItem, mw: Optional[MainWindow]=None, *, will if will_download: if mw is None: raise ValueError('Need mw parameter when will_download=True') - await wait_for_download_to_start_and_finish(mw.task_tree) - await wait_for(first_child_of_tree_item_is_not_loading_condition(node_ti)) + await wait_for_download_to_start_and_finish( + mw.task_tree, + stacklevel_extra=1) + await wait_for( + first_child_of_tree_item_is_not_loading_condition(node_ti), + stacklevel_extra=1) async def _source_name_for_node(node_ti: TreeItem, mw: MainWindow) -> Optional[str]: diff --git a/src/crystal/tests/util/wait.py b/src/crystal/tests/util/wait.py index 4169b938..36ea01bf 100644 --- a/src/crystal/tests/util/wait.py +++ b/src/crystal/tests/util/wait.py @@ -89,6 +89,7 @@ async def wait_for( timeout: Optional[float]=None, *, period: Optional[float]=None, message: Optional[Callable[[], str]]=None, + stacklevel_extra: int=0, ) -> _T: """ Waits up to `timeout` seconds for the specified condition to become non-None, @@ -150,7 +151,7 @@ async def wait_for( soft_timeout, message_suffix_str ), - stacklevel=2) + stacklevel=(2 + stacklevel_extra)) class WaitTimedOut(Exception):