Skip to content

Commit 4a85fb7

Browse files
committed
Add test_slow_callback_duration_logging
1 parent b2c9155 commit 4a85fb7

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

tests/test_qeventloop.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import socket
1212
import subprocess
1313
import sys
14+
import time
1415
from concurrent.futures import ProcessPoolExecutor, ThreadPoolExecutor
1516

1617
import pytest
@@ -791,6 +792,22 @@ async def mycoro():
791792
assert not loop.is_running()
792793

793794

795+
def test_slow_callback_duration_logging(loop, caplog):
796+
async def mycoro():
797+
time.sleep(1)
798+
799+
caplog.clear()
800+
loop.set_debug(True)
801+
loop.slow_callback_duration = 0.1
802+
with caplog.at_level(logging.WARNING):
803+
loop.run_until_complete(mycoro())
804+
assert len(caplog.records) == 1
805+
msg = caplog.records[0].message
806+
assert "Executing" in msg
807+
assert "took" in msg
808+
assert "seconds" in msg
809+
810+
794811
def teardown_module(module):
795812
"""
796813
Remove handlers from all loggers

0 commit comments

Comments
 (0)