Skip to content

Commit 7d8a923

Browse files
committed
add test for loop.run* methods being non-re-entrant.
1 parent fbe32d3 commit 7d8a923

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

tests/test_qeventloop.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,6 +1013,24 @@ def test_run_forever_custom_exit_code(loop, application):
10131013
application.exec_ = orig_exec
10141014

10151015

1016+
def test_loop_non_reentrant(loop):
1017+
async def noop():
1018+
pass
1019+
1020+
async def task():
1021+
t = loop.create_task(noop())
1022+
with pytest.raises(RuntimeError):
1023+
loop.run_forever()
1024+
1025+
with pytest.raises(RuntimeError):
1026+
loop.run_until_complete(t)
1027+
return 43
1028+
1029+
t = loop.create_task(task())
1030+
loop.run_until_complete(t)
1031+
assert t.result() == 43
1032+
1033+
10161034
def test_qeventloop_in_qthread():
10171035
class CoroutineExecutorThread(qasync.QtCore.QThread):
10181036
def __init__(self, coro):

0 commit comments

Comments
 (0)