Skip to content

Commit f233e5a

Browse files
committed
[refactor] Improve exception handling in pytest_pycollect_makeitem_convert_async_functions_to_subclass.
Signed-off-by: Michael Seifert <[email protected]>
1 parent 3020c55 commit f233e5a

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

pytest_asyncio/plugin.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -536,9 +536,16 @@ def pytest_pycollect_makeitem_convert_async_functions_to_subclass(
536536
to AsyncFunction items.
537537
"""
538538
hook_result = yield
539-
node_or_list_of_nodes: Union[
540-
pytest.Item, pytest.Collector, List[Union[pytest.Item, pytest.Collector]], None
541-
] = hook_result.get_result()
539+
try:
540+
node_or_list_of_nodes: Union[
541+
pytest.Item,
542+
pytest.Collector,
543+
List[Union[pytest.Item, pytest.Collector]],
544+
None,
545+
] = hook_result.get_result()
546+
except BaseException as e:
547+
hook_result.force_exception(e)
548+
return
542549
if not node_or_list_of_nodes:
543550
return
544551
if isinstance(node_or_list_of_nodes, Sequence):

0 commit comments

Comments
 (0)