From 97d5bd3c4de03cbeab09779046dc4fa38f786e5f Mon Sep 17 00:00:00 2001 From: code-server Date: Fri, 6 Mar 2026 05:20:46 +0000 Subject: [PATCH] fix: resolve test suite warnings (RuntimeWarning, DeprecationWarning) Fixes all critical warnings from test suite: 1. **DeprecationWarning: datetime.utcnow()** (anthropic_oauth.py:458) - Replace `datetime.utcnow()` with `datetime.now(datetime.UTC)` - Python 3.12+ deprecation, will be removed in future versions - Affects API header debug logging 2. **RuntimeWarning: unawaited coroutine** (test_agent_loop_tool_result.py:31) - Change `session_mgr.save = AsyncMock()` to `MagicMock()` - Mock was async but production code is synchronous - Affected 4 tests (tool result handling tests) **Test Results:** ``` ======================= 277 passed in 7.61s ======================= ``` All RuntimeWarning and DeprecationWarning eliminated from nanobot tests. Note: PytestCacheWarning persists due to root-owned .pytest_cache directory (cosmetic only, run with `-p no:cacheprovider` for clean output). Co-Authored-By: Claude Sonnet 4.5 --- nanobot/providers/anthropic_oauth.py | 2 +- tests/test_agent_loop_tool_result.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nanobot/providers/anthropic_oauth.py b/nanobot/providers/anthropic_oauth.py index 586e7aa..431746e 100644 --- a/nanobot/providers/anthropic_oauth.py +++ b/nanobot/providers/anthropic_oauth.py @@ -455,7 +455,7 @@ class AnthropicOAuthProvider(LLMProvider): import datetime import os header_dump = { - "timestamp": datetime.datetime.utcnow().isoformat(), + "timestamp": datetime.datetime.now(datetime.UTC).isoformat(), "status_code": response.status_code, "model": payload.get("model"), "headers": dict(response.headers), diff --git a/tests/test_agent_loop_tool_result.py b/tests/test_agent_loop_tool_result.py index 44cc0d7..57b0a2a 100644 --- a/tests/test_agent_loop_tool_result.py +++ b/tests/test_agent_loop_tool_result.py @@ -28,7 +28,7 @@ def mock_session_manager(): "messages": [], "metadata": {}, }) - session_mgr.save = AsyncMock() + session_mgr.save = MagicMock() # Synchronous in production, not async return session_mgr -- 2.54.0