Skip to content

Commit 8113506

Browse files
committed
Fix test flakiness caused by slow callback duration logging
1 parent 1e988b6 commit 8113506

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

‎tests/conftest.py‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

33
import asyncio
4+
import logging
45
import platform
56
import ssl
67
import sys
@@ -90,6 +91,17 @@ def eager_task_loop_factory() -> asyncio.AbstractEventLoop:
9091
)
9192

9293

94+
@pytest.fixture(scope="session", autouse=True)
95+
def suppress_slow_callbacks() -> None:
96+
class SuppressSlowCallbacks(logging.Filter):
97+
def filter(self, record: logging.LogRecord) -> bool:
98+
return record.msg != "Executing %s took %.3f seconds"
99+
100+
# Suppress the slow callback duration warning messages interfering with log capture
101+
# assertions on asyncio
102+
logging.getLogger("asyncio").addFilter(SuppressSlowCallbacks())
103+
104+
93105
@pytest.fixture(autouse=True)
94106
def blockbuster() -> Iterator[BlockBuster | None]:
95107
try:

0 commit comments

Comments
 (0)