22
33from unittest .mock import MagicMock
44
5+ import pytest
6+
57from dqlitedbapi .cursor import Cursor
68
79
@@ -15,29 +17,18 @@ def _cursor_with_prior_select() -> Cursor:
1517
1618
1719class TestExecutemanyEmpty :
18- def test_empty_executemany_clears_description (self ) -> None :
20+ @pytest .mark .asyncio
21+ async def test_empty_executemany_clears_description (self ) -> None :
1922 """After executemany([]) the cursor must not appear to hold a
2023 prior SELECT result."""
2124 c = _cursor_with_prior_select ()
22- # Mock _run_sync so we don't need a loop.
23- c ._connection ._run_sync = MagicMock (side_effect = lambda coro : coro .close () or None )
24- c ._connection ._check_thread = MagicMock ()
2525
26- # Directly drive _executemany_async — it's the code we're
27- # verifying. Run it synchronously via a throwaway event loop.
28- import asyncio
26+ async def _noop (* _a : object , ** _kw : object ) -> None :
27+ return None
2928
30- asyncio .run (_run_empty (c ))
29+ c ._execute_async = _noop # type: ignore[method-assign]
30+ await c ._executemany_async ("INSERT INTO t VALUES (?)" , [])
3131
3232 assert c .description is None
3333 assert c ._rows == []
3434 assert c .rowcount == 0
35-
36-
37- async def _run_empty (c : Cursor ) -> None :
38- # Stub _execute_async so we don't need the full connection pathway.
39- async def _noop (* _a : object , ** _kw : object ) -> None :
40- return None
41-
42- c ._execute_async = _noop # type: ignore[method-assign]
43- await c ._executemany_async ("INSERT INTO t VALUES (?)" , [])
0 commit comments