Skip to content

Commit 8db1046

Browse files
authored
Update test_run.py
1 parent ae0dfa4 commit 8db1046

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

tests/test_run.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
1-
import qasync
21
import asyncio
32
import os
4-
from qasync import QApplication
3+
4+
import pytest
5+
6+
import qasync
7+
58

69
def test_run_with_contextmanager(application):
710
async def coro():
811
event_loop = asyncio.get_event_loop()
9-
assert type(event_loop).__name__ == "QIOCPEventLoop" if os.name == 'nt' else "QSelectorEventLoop"
12+
assert (
13+
type(event_loop).__name__ == "QIOCPEventLoop"
14+
if os.name == "nt"
15+
else "QSelectorEventLoop"
16+
)
1017
await asyncio.sleep(0)
1118

19+
asyncio.set_event_loop(None)
1220
qasync.run(coro())
1321

14-
try:
15-
event_loop = asyncio.get_event_loop()
16-
except:
17-
event_loop = None
18-
assert type(event_loop).__name__ != "QIOCPEventLoop" if os.name == 'nt' else "QSelectorEventLoop"
22+
with pytest.raises(RuntimeError):
23+
_ = asyncio.get_event_loop()

0 commit comments

Comments
 (0)