1111 assert_does_open_webbrowser_to , extracted_project ,
1212 served_project_from_filepath ,
1313)
14- from crystal .tests .util .tasks import wait_for_download_to_start_and_finish
14+ from crystal .tests .util .tasks import wait_for_download_task_to_start_and_finish
1515from crystal .tests .util .wait import (
1616 first_child_of_tree_item_is_not_loading_condition , wait_for ,
1717)
@@ -34,8 +34,8 @@ async def test_when_download_html_page_then_does_not_download_embedded_resource_
3434 root_ti = TreeItem .GetRootItem (mw .entity_tree .window )
3535 home_ti = root_ti .GetFirstChild ()
3636 assert home_ti is not None
37- home_ti . Expand ()
38- await wait_for_download_to_start_and_finish ( mw . task_tree )
37+ async with wait_for_download_task_to_start_and_finish ( project ):
38+ home_ti . Expand ( )
3939 assert first_child_of_tree_item_is_not_loading_condition (home_ti )()
4040
4141 # Expand HTML page children in entity tree
@@ -60,8 +60,8 @@ async def test_then_embedded_resource_does_not_appear_in_a_hidden_embedded_clust
6060 root_ti = TreeItem .GetRootItem (mw .entity_tree .window )
6161 home_ti = root_ti .GetFirstChild ()
6262 assert home_ti is not None
63- home_ti . Expand ()
64- await wait_for_download_to_start_and_finish ( mw . task_tree )
63+ async with wait_for_download_task_to_start_and_finish ( project ):
64+ home_ti . Expand ( )
6565 assert first_child_of_tree_item_is_not_loading_condition (home_ti )()
6666
6767 # Expand HTML page children in entity tree
@@ -83,8 +83,8 @@ async def test_when_browse_to_html_page_and_browser_requests_embedded_resource_t
8383 home_ti = root_ti .GetFirstChild ()
8484 assert home_ti is not None
8585 home_ti .SelectItem ()
86- await mw . click_download_button ()
87- await wait_for_download_to_start_and_finish (mw .task_tree )
86+ async with wait_for_download_task_to_start_and_finish ( project ):
87+ click_button (mw .download_button )
8888
8989 # Start server
9090 home_ti .SelectItem ()
@@ -104,8 +104,8 @@ async def test_given_embedded_resource_selected_in_entity_tree_when_press_downlo
104104 root_ti = TreeItem .GetRootItem (mw .entity_tree .window )
105105 home_ti = root_ti .GetFirstChild ()
106106 assert home_ti is not None
107- home_ti . Expand ()
108- await wait_for_download_to_start_and_finish ( mw . task_tree )
107+ async with wait_for_download_task_to_start_and_finish ( project ):
108+ home_ti . Expand ( )
109109 assert first_child_of_tree_item_is_not_loading_condition (home_ti )()
110110
111111 # Expand HTML page children in entity tree
@@ -119,13 +119,8 @@ async def test_given_embedded_resource_selected_in_entity_tree_when_press_downlo
119119 assert not comic_image_r .has_any_revisions ()
120120
121121 comic_image_r_ti .SelectItem ()
122- await mw .click_download_button (
123- # NOTE: May "finish immediately" because has no embedded subresources
124- immediate_finish_ok = True )
125- await wait_for_download_to_start_and_finish (
126- mw .task_tree ,
127- # NOTE: May "finish immediately" because has no embedded subresources
128- immediate_finish_ok = True )
122+ async with wait_for_download_task_to_start_and_finish (project ):
123+ click_button (mw .download_button )
129124 assert comic_image_r .has_any_revisions ()
130125
131126
@@ -137,8 +132,8 @@ async def test_given_do_not_download_group_selected_in_entity_tree_when_press_do
137132 home_ti = root_ti .GetFirstChild ()
138133 assert home_ti is not None
139134 home_ti .SelectItem ()
140- await mw . click_download_button ()
141- await wait_for_download_to_start_and_finish (mw .task_tree )
135+ async with wait_for_download_task_to_start_and_finish ( project ):
136+ click_button (mw .download_button )
142137
143138 # Expand group children in entity tree
144139 comic_image_rg_ti = root_ti .find_child (comic_image_rg_pattern )
@@ -151,8 +146,8 @@ async def test_given_do_not_download_group_selected_in_entity_tree_when_press_do
151146 assert not comic_image_r .has_any_revisions ()
152147
153148 comic_image_rg_ti .SelectItem ()
154- await mw . click_download_button ()
155- await wait_for_download_to_start_and_finish (mw .task_tree )
149+ async with wait_for_download_task_to_start_and_finish ( project ):
150+ click_button (mw .download_button )
156151 assert comic_image_r .has_any_revisions ()
157152
158153
@@ -163,8 +158,8 @@ async def test_then_embedded_resource_in_entity_tree_appears_with_do_not_downloa
163158 root_ti = TreeItem .GetRootItem (mw .entity_tree .window )
164159 home_ti = root_ti .GetFirstChild ()
165160 assert home_ti is not None
166- home_ti . Expand ()
167- await wait_for_download_to_start_and_finish ( mw . task_tree )
161+ async with wait_for_download_task_to_start_and_finish ( project ):
162+ home_ti . Expand ( )
168163 assert first_child_of_tree_item_is_not_loading_condition (home_ti )()
169164
170165 # Expand HTML page children in entity tree
0 commit comments