File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change 11import asyncio
22import logging
33import os
4- from unittest .mock import AsyncMock , patch
4+ from unittest .mock import AsyncMock , MagicMock , patch
55
66import pytest
77import pytest_asyncio
@@ -188,6 +188,9 @@ async def test_load_remote_resources(mock_client):
188188
189189 finally :
190190 # Clean up
191+ for resource in DownloadManager ._REMOTE_RESOURCES_CACHE .values ():
192+ if asyncio .iscoroutine (resource ):
193+ await resource
191194 DownloadManager ._REMOTE_RESOURCES_CACHE .clear ()
192195
193196
@@ -314,14 +317,14 @@ async def test_close_remote_resources():
314317 # Arrange
315318 mock_task = AsyncMock (spec = asyncio .Task )
316319 mock_awaitable = AsyncMock ()
317- mock_awaitable .__await__ = AsyncMock (
318- return_value = iter ([None ])
319- ) # Make it properly awaitable
320+ mock_awaitable .__await__ = AsyncMock (return_value = iter ([None ]))
320321
321322 # Configure mock task
322323 mock_task .done .return_value = False
323324 mock_task .cancelled .return_value = False
324- mock_task .cancel = AsyncMock ()
325+ mock_task .cancel = (
326+ MagicMock ()
327+ ) # Use regular MagicMock instead of AsyncMock for cancel
325328
326329 # Store original cache
327330 original_cache = DownloadManager ._REMOTE_RESOURCES_CACHE .copy ()
@@ -338,7 +341,6 @@ async def test_close_remote_resources():
338341
339342 # Assert
340343 mock_task .cancel .assert_called_once ()
341- # No need to await mock_awaitable as it's handled in close_remote_resources
342344
343345 finally :
344346 # Restore original cache
You can’t perform that action at this time.
0 commit comments