Skip to content

Commit 59dd9b3

Browse files
committed
Create loop if not already running
1 parent 9c86bb7 commit 59dd9b3

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

tests/test_eventloop.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,11 @@ def test_asyncio_loop(kernel):
8383
def do_thing():
8484
loop.call_later(0.01, loop.stop)
8585

86-
loop = asyncio.get_event_loop()
86+
try:
87+
loop = asyncio.get_event_loop()
88+
except RuntimeError:
89+
loop = asyncio.new_event_loop()
90+
asyncio.set_event_loop(loop)
8791
loop.call_soon(do_thing)
8892
loop_asyncio(kernel)
8993

@@ -128,7 +132,10 @@ def test_qt_enable_gui(kernel, capsys):
128132

129133
enable_gui(not_gui, kernel)
130134
captured = capsys.readouterr()
131-
assert captured.out == f"Cannot switch Qt versions for this session; you must use {gui}.\n"
135+
assert (
136+
captured.out
137+
== f"Cannot switch Qt versions for this session; you must use {gui}.\n"
138+
)
132139

133140
# Check 'qt' gui, which means "the best available"
134141
enable_gui(None, kernel)

0 commit comments

Comments
 (0)