@@ -47,6 +47,11 @@ async def test_get_db_session_raises_before_init(self) -> None:
4747 await anext (gen )
4848
4949
50+ async def noop (** _kwargs : object ) -> None :
51+ """A no-op async function that accepts arbitrary keyword arguments."""
52+ await asyncio .sleep (0 )
53+
54+
5055class TestInitEngine :
5156 """Tests for init_engine and dispose_engine lifecycle."""
5257
@@ -61,10 +66,6 @@ async def test_init_engine_is_idempotent(self, sqlite_url: str) -> None:
6166 """Calling init_engine twice is a no-op — execute_with_session works after both calls."""
6267 init_engine (sqlite_url )
6368 init_engine (sqlite_url ) # Must not raise; second call is a silent no-op
64-
65- async def noop (** _kwargs : object ) -> None :
66- pass
67-
6869 await execute_with_session (noop ) # Session maker still functional
6970
7071 @pytest .mark .unit
@@ -82,7 +83,8 @@ async def test_execute_with_session_passes_session(self, sqlite_url: str) -> Non
8283 """The wrapped function receives an AsyncSession as the 'session' keyword argument."""
8384 received : list [object ] = []
8485
85- async def capture_session (** kwargs : object ) -> None : # noqa: RUF029
86+ async def capture_session (** kwargs : object ) -> None :
87+ await asyncio .sleep (0 ) # Use an asynchronous feature
8688 received .append (kwargs .get (SESSION_KWARG ))
8789
8890 init_engine (sqlite_url )
@@ -94,10 +96,6 @@ async def capture_session(**kwargs: object) -> None: # noqa: RUF029
9496 @pytest .mark .unit
9597 async def test_execute_with_session_raises_before_init (self ) -> None :
9698 """RuntimeError raised when execute_with_session is called before init_engine."""
97-
98- async def noop (** _ : object ) -> None :
99- pass
100-
10199 with pytest .raises (RuntimeError , match = "not initialized" ):
102100 await execute_with_session (noop )
103101
@@ -109,7 +107,8 @@ class TestCliRunWithDb:
109107 async def test_cli_run_with_db_returns_function_result (self , sqlite_url : str ) -> None :
110108 """cli_run_with_db returns the value produced by the async function."""
111109
112- async def return_42 (** _ : object ) -> int : # noqa: RUF029
110+ async def return_42 (** _ : object ) -> int :
111+ await asyncio .sleep (0 ) # Use an asynchronous feature
113112 return 42
114113
115114 result = await asyncio .to_thread (cli_run_with_db , return_42 , db_url = sqlite_url )
@@ -127,10 +126,6 @@ async def raise_error(**_: object) -> None: # noqa: RUF029
127126 with pytest .raises (ValueError , match = err_msg ):
128127 await asyncio .to_thread (cli_run_with_db , raise_error , db_url = sqlite_url )
129128
130- # Engine was cleaned up; init_engine followed by execute_with_session must work.
131- async def noop (** _ : object ) -> None :
132- pass
133-
134129 init_engine (sqlite_url )
135130 await execute_with_session (noop )
136131
@@ -142,7 +137,8 @@ class TestCliRunWithEngine:
142137 async def test_cli_run_with_engine_executes_function (self , sqlite_url : str ) -> None :
143138 """cli_run_with_engine returns the value produced by the async function."""
144139
145- async def return_hello () -> str : # noqa: RUF029
140+ async def return_hello () -> str :
141+ await asyncio .sleep (0 ) # Use an asynchronous feature
146142 return "hello"
147143
148144 result = await asyncio .to_thread (cli_run_with_engine , return_hello , db_url = sqlite_url )
@@ -160,10 +156,6 @@ async def raise_error() -> None: # noqa: RUF029
160156 with pytest .raises (ValueError , match = err_msg ):
161157 await asyncio .to_thread (cli_run_with_engine , raise_error , db_url = sqlite_url )
162158
163- # Engine was cleaned up; init_engine followed by execute_with_session must work.
164- async def noop (** _ : object ) -> None :
165- pass
166-
167159 init_engine (sqlite_url )
168160 await execute_with_session (noop )
169161
0 commit comments