File tree 1 file changed +7
-4
lines changed
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(
709
709
) -> Iterator [asyncio .AbstractEventLoop ]:
710
710
new_loop_policy = event_loop_policy
711
711
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 ())
714
713
asyncio .set_event_loop (loop )
715
714
yield loop
716
715
loop .close ()
@@ -885,6 +884,11 @@ def pytest_fixture_setup(
885
884
yield
886
885
887
886
887
+ def _make_pytest_asyncio_loop (loop : AbstractEventLoop ) -> AbstractEventLoop :
888
+ loop .__pytest_asyncio = True # type: ignore[attr-defined]
889
+ return loop
890
+
891
+
888
892
def _is_pytest_asyncio_loop (loop : AbstractEventLoop ) -> bool :
889
893
return getattr (loop , "__pytest_asyncio" , False )
890
894
@@ -1161,8 +1165,7 @@ def _session_event_loop(
1161
1165
) -> Iterator [asyncio .AbstractEventLoop ]:
1162
1166
new_loop_policy = event_loop_policy
1163
1167
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 ())
1166
1169
asyncio .set_event_loop (loop )
1167
1170
yield loop
1168
1171
loop .close ()
You can’t perform that action at this time.
0 commit comments