Skip to content

Commit 2ed7c60

Browse files
committed
PYTHON-5071 Ignore get_event_loop deprecation
1 parent c08fceb commit 2ed7c60

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

test/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,10 @@ class PyMongoTestCase(unittest.TestCase):
885885
def __init__(self, methodName="runTest"):
886886
super().__init__(methodName)
887887
try:
888-
self.loop = asyncio.get_event_loop()
888+
with warnings.catch_warnings():
889+
# Ignore DeprecationWarning: There is no current event loop
890+
warnings.simplefilter("ignore", DeprecationWarning)
891+
self.loop = asyncio.get_event_loop()
889892
except RuntimeError:
890893
self.loop = asyncio.new_event_loop()
891894
asyncio.set_event_loop(self.loop)

test/asynchronous/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,10 @@ class AsyncPyMongoTestCase(unittest.TestCase):
887887
def __init__(self, methodName="runTest"):
888888
super().__init__(methodName)
889889
try:
890-
self.loop = asyncio.get_event_loop()
890+
with warnings.catch_warnings():
891+
# Ignore DeprecationWarning: There is no current event loop
892+
warnings.simplefilter("ignore", DeprecationWarning)
893+
self.loop = asyncio.get_event_loop()
891894
except RuntimeError:
892895
self.loop = asyncio.new_event_loop()
893896
asyncio.set_event_loop(self.loop)

0 commit comments

Comments
 (0)