lplalbert opened a new pull request, #425:
URL: https://github.com/apache/hugegraph-ai/pull/425

   ## Problem
   
   `index_op` test runs emit "coroutine ... was never awaited" RuntimeWarnings 
(3 per run, surfaced at GC).
   
   ## Root cause
   
   `patch()` creates an **AsyncMock** when its target is an async function. The 
builder tests mock both `get_embeddings_parallel` (async) **and** `asyncio.run` 
— calling the auto-AsyncMock produces a coroutine, and the mocked `asyncio.run` 
discards that call result instead of awaiting it, leaving the coroutine 
un-awaited behind.
   
   ## Fix
   
   Force `new_callable=MagicMock` for these mocks so the mocked call returns a 
plain value — exactly the pattern `test_build_gremlin_example_index` already 
uses for the same double-mock structure (the working comparison). Assertions 
and coverage are unchanged.
   
   Sibling search (same failure class elsewhere): only 
`test_build_semantic_index`'s two `run()` tests (`patch.object` on the async 
`_get_embeddings_parallel` + mocked `asyncio.run`) — fixed here too. Note PR 
#424 rewrites those same tests and drops the `asyncio.run` mock entirely (which 
also removes the leak there); whichever lands second rebases mechanically — 
same root cause grouped here.
   
   ## Validation (executed locally)
   
   - `PYTHONTRACEMALLOC=2 ... pytest 
hugegraph-llm/src/tests/operators/index_op/ 
hugegraph-llm/src/tests/nodes/index_node/` -> **3 "was never awaited" warnings 
before, 0 after** (traces attribute every instance to the patched async helper 
called under the mocked `asyncio.run`)
   - `SKIP_EXTERNAL_SERVICES=true uv run pytest hugegraph-llm/src/tests` -> 
**1289 passed, 12 skipped, 2 failed** — the two `test_external_config.py` 
failures also fail on clean `origin/main` (verified via stash), pre-existing 
and unrelated
   - `uv run --extra dev ruff format --check` + `ruff check` clean; `ty check` 
on the changed files: all checks passed
   
   Refs #107
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to