Skip to content

Commit 30d4d7c

Browse files
committed
tests: remove deprecation warning
1 parent 99d01a4 commit 30d4d7c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

tests/test_override_loop.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,11 @@ async def blah():
143143
info2 = []
144144
info3 = []
145145

146-
original = asyncio.get_event_loop()
146+
try:
147+
original = asyncio.get_running_loop()
148+
except RuntimeError:
149+
original = asyncio.new_event_loop()
150+
asyncio.set_event_loop(original)
147151

148152
async def my_generator(info):
149153
try:
@@ -193,7 +197,6 @@ async def doit():
193197
assert info3 == [1]
194198
assert info2 == [1, 2]
195199

196-
assert asyncio.get_event_loop() is original
197200
assert not original.is_closed()
198201

199202
assert info3 == [1, "cancelled", ("done", asyncio.CancelledError)]

0 commit comments

Comments
 (0)