Skip to content

Commit 0e9d362

Browse files
GeneAIclaude
authored andcommitted
fix: Fix remaining Windows CI test failures
- Add mock_anthropic fixture to test_claude_memory.py - Skip test_invalid_api_key when anthropic not installed - Fix timing assertion in test_base_wizard.py (>= 0 vs > 0) - Fix path assertion in test_claude_memory_extended.py (# User vs User) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 79408d9 commit 0e9d362

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

tests/test_base_wizard.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ def test_full_analysis_without_context(self):
226226
assert len(result.issues) == 3 # Our test implementation returns 3
227227
assert len(result.predictions) == 0 # No predictions without context
228228
assert result.analyzed_files == 1
229-
assert result.analysis_time > 0
229+
assert result.analysis_time >= 0 # May be 0.0 on fast systems
230230
assert isinstance(result.summary, str)
231231

232232
def test_full_analysis_with_context(self):

tests/test_claude_memory.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import tempfile
1111
from pathlib import Path
12+
from unittest.mock import MagicMock, patch
1213

1314
import pytest
1415

@@ -19,6 +20,16 @@
1920
)
2021

2122

23+
@pytest.fixture
24+
def mock_anthropic():
25+
"""Mock anthropic module so tests don't require actual package"""
26+
mock_module = MagicMock()
27+
mock_client = MagicMock()
28+
mock_module.Anthropic.return_value = mock_client
29+
with patch.dict("sys.modules", {"anthropic": mock_module}):
30+
yield mock_module
31+
32+
2233
@pytest.fixture
2334
def temp_project_dir():
2435
"""Create a temporary project directory"""
@@ -252,7 +263,7 @@ def test_dont_overwrite_existing(sample_claude_memory):
252263

253264

254265
@pytest.mark.asyncio
255-
async def test_integration_with_empathy_llm(sample_claude_memory):
266+
async def test_integration_with_empathy_llm(sample_claude_memory, mock_anthropic):
256267
"""Test integration of Claude memory with EmpathyLLM"""
257268
from empathy_llm_toolkit import EmpathyLLM
258269

@@ -274,7 +285,7 @@ async def test_integration_with_empathy_llm(sample_claude_memory):
274285

275286

276287
@pytest.mark.asyncio
277-
async def test_reload_memory(sample_claude_memory):
288+
async def test_reload_memory(sample_claude_memory, mock_anthropic):
278289
"""Test reloading memory after changes"""
279290
from empathy_llm_toolkit import EmpathyLLM
280291

tests/test_claude_memory_extended.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,8 @@ def test_selective_level_loading(self, temp_project_dir, mock_home_dir):
540540
memory = loader.load_all_memory(temp_project_dir)
541541

542542
assert "Enterprise" in memory
543-
assert "User" not in memory
543+
# Check for user memory content marker, not just "User" (Windows paths may contain "Users")
544+
assert "# User" not in memory
544545
assert "Project" in memory
545546

546547

tests/test_llm_integration.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,11 +291,10 @@ class TestLLMErrorHandling:
291291

292292
@pytest.mark.llm
293293
@pytest.mark.asyncio
294+
@pytest.mark.skipif(anthropic is None, reason="anthropic package not installed")
294295
async def test_invalid_api_key(self):
295296
"""Test handling of invalid API key"""
296-
expected_exceptions = (ValueError, RuntimeError)
297-
if anthropic is not None:
298-
expected_exceptions = (ValueError, RuntimeError, anthropic.AuthenticationError)
297+
expected_exceptions = (ValueError, RuntimeError, anthropic.AuthenticationError)
299298
with pytest.raises(expected_exceptions):
300299
provider = AnthropicProvider(api_key="invalid-key-12345")
301300
await provider.generate(messages=[{"role": "user", "content": "Hello"}], max_tokens=50)

0 commit comments

Comments
 (0)