Skip to content

Commit fb4d1c0

Browse files
committed
fixup for windows
1 parent a683244 commit fb4d1c0

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

tests/test_sync.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def test_sync_timeout() -> None:
6868
async def foo() -> None:
6969
await asyncio.sleep(duration)
7070

71-
with pytest.raises(asyncio.TimeoutError):
71+
with pytest.raises(TimeoutError):
7272
sync(foo(), timeout=duration / 10)
7373

7474

@@ -224,14 +224,16 @@ def test_create_event_loop_windows_no_uvloop() -> None:
224224
loop.close()
225225

226226

227+
@pytest.mark.skipif(sys.platform == "win32", reason="uvloop is not supported on Windows")
227228
def test_uvloop_mock_import_error(clean_state) -> None:
228229
"""Test graceful handling when uvloop import fails."""
229230
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
231233
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

Comments
 (0)