We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2b7326e commit 04c07e3Copy full SHA for 04c07e3
1 file changed
tests/conftest.py
@@ -50,6 +50,24 @@
50
from prometheus_client import CollectorRegistry
51
52
53
+@pytest.fixture(autouse=True)
54
+def reset_uvicorn_logger_propagation():
55
+ """Reset uvicorn logger state between tests.
56
+
57
+ Uvicorn's configure_logging() sets uvicorn.access.propagate=False via its
58
+ default LOGGING_CONFIG when a server starts. This leaks into subsequent tests
59
+ that assert stdlib loggers propagate to the root handler.
60
+ """
61
+ yield
62
+ import logging
63
64
+ for name in ("uvicorn.access", "uvicorn.error", "uvicorn"):
65
+ lg = logging.getLogger(name)
66
+ lg.propagate = True
67
+ for h in lg.handlers[:]:
68
+ lg.removeHandler(h)
69
70
71
@pytest.fixture(autouse=True)
72
def reset_sse_starlette_app_status():
73
"""
0 commit comments