Skip to content

Commit fdacaa2

Browse files
committed
Add set_event_loop_policy to backports
Since it's been deprecated in newer Python versions
1 parent 4221c21 commit fdacaa2

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

Diff for: mock/backports.py

+6
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,9 @@ def run(self, result=None):
9090
return super().run(result)
9191
finally:
9292
self._tearDownAsyncioLoop()
93+
94+
95+
try:
96+
from asyncio import _set_event_loop_policy as set_event_loop_policy
97+
except ImportError:
98+
from asyncio import set_event_loop_policy

Diff for: mock/tests/testasync.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from mock import (ANY, call, AsyncMock, patch, MagicMock, Mock,
1010
create_autospec, sentinel, seal)
11-
from mock.backports import IsolatedAsyncioTestCase, iscoroutinefunction
11+
from mock.backports import IsolatedAsyncioTestCase, iscoroutinefunction, set_event_loop_policy
1212
from mock.mock import _CallList
1313

1414

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

2626

2727
def tearDownModule():
28-
asyncio._set_event_loop_policy(None)
28+
set_event_loop_policy(None)
2929

3030

3131
class AsyncClass:

0 commit comments

Comments
 (0)