File tree Expand file tree Collapse file tree 1 file changed +6
-10
lines changed Expand file tree Collapse file tree 1 file changed +6
-10
lines changed Original file line number Diff line number Diff line change @@ -48,20 +48,16 @@ async def wait_for_download_task_to_start_and_finish(
4848 """
4949 period = DEFAULT_WAIT_PERIOD
5050
51- appended_tasks = []
52-
53- super_append_child = project .root_task .append_child
54- def spy_append_child (child : Task , * args , ** kwargs ):
55- appended_tasks .append (child )
56- return super_append_child (child , * args , ** kwargs )
57- project .root_task .append_child = spy_append_child # type: ignore[method-assign]
58- try :
51+ with patch .object (
52+ project .root_task ,
53+ 'append_child' ,
54+ wraps = project .root_task .append_child
55+ ) as spy_append_child :
5956 # Take action that should append a top-level task
6057 yield
61- finally :
62- project .root_task .append_child = super_append_child # type: ignore[method-assign]
6358
6459 # Locate appended top-level task
60+ appended_tasks = [c .args [0 ] for c in spy_append_child .call_args_list ]
6561 if type is not None :
6662 appended_tasks = [t for t in appended_tasks if isinstance (t , type )] # reinterpret
6763 if len (appended_tasks ) != 1 :
You can’t perform that action at this time.
0 commit comments