Skip to content

Commit 1818e67

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 0de8dce commit 1818e67

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
@@ -542,9 +542,16 @@ def pytest_pycollect_makeitem_convert_async_functions_to_subclass(
542542
to AsyncFunction items.
543543
"""
544544
hook_result = yield
545-
node_or_list_of_nodes: Union[
546-
pytest.Item, pytest.Collector, List[Union[pytest.Item, pytest.Collector]], None
547-
] = hook_result.get_result()
545+
try:
546+
node_or_list_of_nodes: Union[
547+
pytest.Item,
548+
pytest.Collector,
549+
List[Union[pytest.Item, pytest.Collector]],
550+
None,
551+
] = hook_result.get_result()
552+
except BaseException as e:
553+
hook_result.force_exception(e)
554+
return
548555
if not node_or_list_of_nodes:
549556
return
550557
if isinstance(node_or_list_of_nodes, Sequence):

0 commit comments

Comments
 (0)