Repository navigation
Conversation
patch() creates an AsyncMock when its target is an async function, so mocking get_embeddings_parallel / _get_embeddings_parallel produced a coroutine per call; these tests also mock asyncio.run, which discards that call's result and leaves the coroutine un-awaited. pytest surfaced 'coroutine ... was never awaited' RuntimeWarnings at GC (3 per index_op run). Force MagicMock for these mocks - the pattern test_build_gremlin_example_index already uses - so the mocked call returns a plain value. Assertions and coverage are unchanged. Sibling search found no other occurrences: the gremlin builder tests (new_callable=MagicMock) are the working comparison. Validation: index_op + index_node runs go from 3 'was never awaited' warnings to 0 (PYTHONTRACEMALLOC attributes every instance to the patched async helper called under the mocked asyncio.run); full suite 1289 passed, 12 skipped, 2 failed = the pre-existing test_external_config pair that also fails on origin/main; ruff/ty clean on the changed files. Co-Authored-By: Claude Code <noreply@anthropic.com>
bitflicker64
left a comment
There was a problem hiding this comment.
Blocking: no. Score: 9/10. Summary: Forcing new_callable=MagicMock on the patched async embedding helpers removes the 3 un-awaited AsyncMock coroutines in the index_op tests without changing assertions, matching test_build_gremlin_example_index.py.
imbajin
left a comment
There was a problem hiding this comment.
Score: 8.8/10 · Confidence: high
Blocking: no
Summary
The async helper mocks are used under mocked asyncio.run; returning plain values removes discarded coroutine objects without changing the existing assertions.
Evidence
Reviewed both changed test files and builder call paths; separate semantic helper tests exercise its async behavior. LLM Python 3.12 and quality CI succeeded.
Validation notes
Static review; the reported warning counts were not independently reproduced.
Problem
index_optest 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 bothget_embeddings_parallel(async) andasyncio.run— calling the auto-AsyncMock produces a coroutine, and the mockedasyncio.rundiscards that call result instead of awaiting it, leaving the coroutine un-awaited behind.Fix
Force
new_callable=MagicMockfor these mocks so the mocked call returns a plain value — exactly the patterntest_build_gremlin_example_indexalready 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 tworun()tests (patch.objecton the async_get_embeddings_parallel+ mockedasyncio.run) — fixed here too. Note PR #424 rewrites those same tests and drops theasyncio.runmock 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 mockedasyncio.run)SKIP_EXTERNAL_SERVICES=true uv run pytest hugegraph-llm/src/tests-> 1289 passed, 12 skipped, 2 failed — the twotest_external_config.pyfailures also fail on cleanorigin/main(verified via stash), pre-existing and unrelateduv run --extra dev ruff format --check+ruff checkclean;ty checkon the changed files: all checks passedRefs #107
🤖 Generated with Claude Code