Skip to content

Commit c9d40c4

Browse files
DX-119753: stabilize MCP logging tests
1 parent 1ee3470 commit c9d40c4

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

tests/servers/test_jwks_verifier.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
from mcp.shared.context import RequestContext
3333
from starlette.requests import Request
3434

35+
from dremioai import log
3536
from dremioai.servers.jwks_verifier import JWKSVerifier, VerifiedClaims, TokenExpiredError
3637
from dremioai.servers.mcp import make_logged_invoke, RequireAuthWithWWWAuthenticateMiddleware
3738

@@ -274,6 +275,15 @@ async def test_dispatch_logs_warning_on_401(self, caplog):
274275
class TestMakeLoggedInvoke:
275276
"""Tests for make_logged_invoke WARNING logging on tool exceptions."""
276277

278+
@pytest.fixture
279+
def info_logging(self):
280+
previous_level = log.level()
281+
log.set_level(logging.INFO)
282+
try:
283+
yield
284+
finally:
285+
log.set_level(previous_level)
286+
277287
@pytest.mark.asyncio
278288
async def test_logs_warning_on_exception(self, caplog):
279289
async def failing_fn():
@@ -302,7 +312,7 @@ async def ok_fn():
302312
assert len(warning_records) == 0
303313

304314
@pytest.mark.asyncio
305-
async def test_logs_info_on_success(self, caplog):
315+
async def test_logs_info_on_success(self, caplog, info_logging):
306316
async def ok_fn():
307317
return "ok"
308318

@@ -319,7 +329,7 @@ async def ok_fn():
319329
)
320330

321331
@pytest.mark.asyncio
322-
async def test_logs_mcp_request_context(self, caplog):
332+
async def test_logs_mcp_request_context(self, caplog, info_logging):
323333
async def ok_fn():
324334
return "ok"
325335

0 commit comments

Comments
 (0)