Skip to content

Commit

Permalink
Add set_event_loop_policy to backports
Browse files Browse the repository at this point in the history
Since it's been deprecated in newer Python versions
  • Loading branch information
cjw296 committed Mar 3, 2025
1 parent 4221c21 commit fdacaa2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions mock/backports.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,9 @@ def run(self, result=None):
return super().run(result)
finally:
self._tearDownAsyncioLoop()


try:
from asyncio import _set_event_loop_policy as set_event_loop_policy
except ImportError:
from asyncio import set_event_loop_policy
4 changes: 2 additions & 2 deletions mock/tests/testasync.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from mock import (ANY, call, AsyncMock, patch, MagicMock, Mock,
create_autospec, sentinel, seal)
from mock.backports import IsolatedAsyncioTestCase, iscoroutinefunction
from mock.backports import IsolatedAsyncioTestCase, iscoroutinefunction, set_event_loop_policy
from mock.mock import _CallList


Expand All @@ -25,7 +25,7 @@ def run(main):


def tearDownModule():
asyncio._set_event_loop_policy(None)
set_event_loop_policy(None)


class AsyncClass:
Expand Down

0 comments on commit fdacaa2

Please sign in to comment.