Commit 4b18790
authored
fix: pytest coroutine warnings (#227)
Root cause**: All three warnings came from tests of the `main()`
function, where `asyncio.run` was mocked but `run_proxy(args)` still
created coroutines that were never awaited:
1. **`test_main_default`** in `test_main.py` —
`@patch('mcp_proxy_for_aws.server.run_proxy')` auto-detected the async
function and created an `AsyncMock`. Calling it produced a coroutine
passed to the mocked `asyncio.run`, which never awaited it.
2. **`test_main_function`** in `test_server.py` — `run_proxy` wasn't
patched at all, so the real `async def run_proxy(args)` created a real
coroutine that the mocked `asyncio.run` discarded.
3. **`test_main_error_handling`** in `test_server.py` — Same issue as
**Fix**: Added `@patch('mcp_proxy_for_aws.server.run_proxy',
new_callable=Mock)` to all three tests. Using `new_callable=Mock` forces
a regular `Mock` instead of an `AsyncMock`, so calling
`mock_run_proxy(args)` returns a plain `MagicMock` (not a coroutine),
which is safely passed to the mocked `asyncio.run` without any unawaited
coroutine issues.1 parent c950d74 commit 4b18790
2 files changed
+6
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | 29 | | |
33 | 30 | | |
34 | 31 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
364 | 364 | | |
365 | 365 | | |
366 | 366 | | |
| 367 | + | |
367 | 368 | | |
368 | | - | |
| 369 | + | |
369 | 370 | | |
370 | 371 | | |
371 | 372 | | |
| |||
377 | 378 | | |
378 | 379 | | |
379 | 380 | | |
| 381 | + | |
380 | 382 | | |
381 | | - | |
| 383 | + | |
382 | 384 | | |
383 | 385 | | |
384 | 386 | | |
| |||
0 commit comments