Skip to content

Commit d8d3cfd

Browse files
fix: update test to mock asyncio.sleep instead of time.sleep
1 parent 15b84c4 commit d8d3cfd

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

tests/unit/rules/conditions/test_llm_assisted.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ async def test_graceful_degradation_on_llm_failure(self, mock_get_chat_model, co
196196
assert violations == []
197197

198198
@pytest.mark.asyncio
199-
@patch("time.sleep", return_value=None) # Mock sleep to speed up test
199+
@patch("asyncio.sleep", new_callable=AsyncMock) # Mock async sleep to speed up test
200200
@patch("src.integrations.providers.get_chat_model")
201201
async def test_retry_logic_with_exponential_backoff(self, mock_get_chat_model, mock_sleep, condition):
202202
"""When structured invoke fails, retries with exponential backoff."""
@@ -213,7 +213,7 @@ async def test_retry_logic_with_exponential_backoff(self, mock_get_chat_model, m
213213
# Should have retried 3 times total
214214
assert mock_structured.ainvoke.await_count == 3
215215
# Should have slept twice (2s, 4s)
216-
assert mock_sleep.call_count == 2
216+
assert mock_sleep.await_count == 2
217217

218218
@pytest.mark.asyncio
219219
@patch("src.integrations.providers.get_chat_model")

0 commit comments

Comments
 (0)