File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -709,8 +709,7 @@ def scoped_event_loop(
709709 ) -> Iterator [asyncio .AbstractEventLoop ]:
710710 new_loop_policy = event_loop_policy
711711 with _temporary_event_loop_policy (new_loop_policy ):
712- loop = asyncio .new_event_loop ()
713- loop .__pytest_asyncio = True # type: ignore[attr-defined]
712+ loop = _make_pytest_asyncio_loop (asyncio .new_event_loop ())
714713 asyncio .set_event_loop (loop )
715714 yield loop
716715 loop .close ()
@@ -885,6 +884,11 @@ def pytest_fixture_setup(
885884 yield
886885
887886
887+ def _make_pytest_asyncio_loop (loop : AbstractEventLoop ) -> AbstractEventLoop :
888+ loop .__pytest_asyncio = True # type: ignore[attr-defined]
889+ return loop
890+
891+
888892def _is_pytest_asyncio_loop (loop : AbstractEventLoop ) -> bool :
889893 return getattr (loop , "__pytest_asyncio" , False )
890894
@@ -1161,8 +1165,7 @@ def _session_event_loop(
11611165) -> Iterator [asyncio .AbstractEventLoop ]:
11621166 new_loop_policy = event_loop_policy
11631167 with _temporary_event_loop_policy (new_loop_policy ):
1164- loop = asyncio .new_event_loop ()
1165- loop .__pytest_asyncio = True # type: ignore[attr-defined]
1168+ loop = _make_pytest_asyncio_loop (asyncio .new_event_loop ())
11661169 asyncio .set_event_loop (loop )
11671170 yield loop
11681171 loop .close ()
You can’t perform that action at this time.
0 commit comments