File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55
66import qasync
77
8-
9- def test_run_with_contextmanager ( application ):
8+ @ pytest . fixture
9+ def get_event_loop_coro ( expected_loop ):
1010 async def coro ():
1111 event_loop = asyncio .get_event_loop ()
12- assert (
13- type (event_loop ).__name__ == "QIOCPEventLoop"
14- if os .name == "nt"
15- else "QSelectorEventLoop"
16- )
12+
13+ assert type (event_loop ).__name__ == expected_loop
1714 await asyncio .sleep (0 )
15+ return coro
16+
17+ @pytest .fixture
18+ def expected_loop ():
19+ return "QIOCPEventLoop" if os .name == "nt" else "QSelectorEventLoop"
1820
21+ def test_run_with_contextmanager (get_event_loop_coro ):
1922 asyncio .set_event_loop (None )
20- qasync .run (coro ())
23+ qasync .run (get_event_loop_coro ())
2124
2225 with pytest .raises (RuntimeError ):
2326 _ = asyncio .get_event_loop ()
27+
28+ def test_run_with_existing_eventloop (get_event_loop_coro , expected_loop ):
29+ asyncio .set_event_loop (asyncio .new_event_loop ())
30+ qasync .run (get_event_loop_coro ())
31+ assert asyncio .get_event_loop () != expected_loop
You can’t perform that action at this time.
0 commit comments