@@ -68,7 +68,7 @@ def test_sync_timeout() -> None:
68
68
async def foo () -> None :
69
69
await asyncio .sleep (duration )
70
70
71
- with pytest .raises (asyncio . TimeoutError ):
71
+ with pytest .raises (TimeoutError ):
72
72
sync (foo (), timeout = duration / 10 )
73
73
74
74
@@ -224,14 +224,16 @@ def test_create_event_loop_windows_no_uvloop() -> None:
224
224
loop .close ()
225
225
226
226
227
+ @pytest .mark .skipif (sys .platform == "win32" , reason = "uvloop is not supported on Windows" )
227
228
def test_uvloop_mock_import_error (clean_state ) -> None :
228
229
"""Test graceful handling when uvloop import fails."""
229
230
with zarr .config .set ({"async.use_uvloop" : True }):
230
- # Mock uvloop import failure
231
+ # Mock uvloop import failure by putting None in sys.modules
232
+ # This simulates the module being unavailable/corrupted
231
233
with patch .dict ("sys.modules" , {"uvloop" : None }):
232
- with patch ( "builtins.__import__" , side_effect = ImportError ( "No module named ' uvloop'" )):
233
- loop = _create_event_loop ()
234
- # Should fall back to asyncio
235
- assert isinstance (loop , asyncio .AbstractEventLoop )
236
- assert "uvloop" not in str (type (loop ))
237
- loop .close ()
234
+ # When Python tries to import uvloop, it will get None and treat it as ImportError
235
+ loop = _create_event_loop ()
236
+ # Should fall back to asyncio
237
+ assert isinstance (loop , asyncio .AbstractEventLoop )
238
+ assert "uvloop" not in str (type (loop ))
239
+ loop .close ()
0 commit comments