@@ -754,19 +754,6 @@ def _temporary_event_loop_policy(policy: AbstractEventLoopPolicy) -> Iterator[No
754754 try :
755755 yield
756756 finally :
757- # Try detecting user-created event loops that were left unclosed
758- # at the end of a test.
759- try :
760- current_loop : AbstractEventLoop | None = _get_event_loop_no_warn ()
761- except RuntimeError :
762- current_loop = None
763- if current_loop is not None and not current_loop .is_closed ():
764- warnings .warn (
765- _UNCLOSED_EVENT_LOOP_WARNING % current_loop ,
766- DeprecationWarning ,
767- )
768- current_loop .close ()
769-
770757 asyncio .set_event_loop_policy (old_loop_policy )
771758 # When a test uses both a scoped event loop and the event_loop fixture,
772759 # the "_provide_clean_event_loop" finalizer of the event_loop fixture
@@ -820,20 +807,6 @@ def _is_pytest_asyncio_loop(loop: AbstractEventLoop) -> bool:
820807 return getattr (loop , "__pytest_asyncio" , False )
821808
822809
823- _UNCLOSED_EVENT_LOOP_WARNING = dedent (
824- """\
825- pytest-asyncio detected an unclosed event loop when tearing down the event_loop
826- fixture: %r
827- pytest-asyncio will close the event loop for you, but future versions of the
828- library will no longer do so. In order to ensure compatibility with future
829- versions, please make sure that:
830- 1. Any custom "event_loop" fixture properly closes the loop after yielding it
831- 2. The scopes of your custom "event_loop" fixtures do not overlap
832- 3. Your code does not modify the event loop in async fixtures or tests
833- """
834- )
835-
836-
837810def _get_event_loop_no_warn (
838811 policy : AbstractEventLoopPolicy | None = None ,
839812) -> asyncio .AbstractEventLoop :
0 commit comments