Skip to content

test: make Gemini async integration test robust across pytest async modes#140

Open
shuofengzhang wants to merge 2 commits into
alexzhang13:mainfrom
shuofengzhang:fix-gemini-async-integration-test
Open

test: make Gemini async integration test robust across pytest async modes#140
shuofengzhang wants to merge 2 commits into
alexzhang13:mainfrom
shuofengzhang:fix-gemini-async-integration-test

Conversation

@shuofengzhang

Copy link
Copy Markdown

What changed

  • Updated tests/clients/test_gemini.py integration test test_async_completion from an async def pytest test to a synchronous test that calls asyncio.run(...).
  • Added import asyncio for the wrapper call.

Why

  • The integration test is guarded by GEMINI_API_KEY, so it is often skipped in CI/local runs.
  • When the key is present and the test actually runs, pytest can fail with:
    • async def functions are not natively supported
  • This happens because the test relies on async test plugin behavior that can vary by pytest/pytest-asyncio mode.

Insight / Why this matters

  • Root cause: the test used plugin-managed async execution for a single integration case that can be skipped most of the time, so breakage is easy to miss until someone runs with real credentials.
  • Why easy to miss: default/CI environments without GEMINI_API_KEY skip this path, masking the failure mode.
  • Tradeoff: asyncio.run(...) makes the test self-contained and independent of async test plugin mode; this slightly reduces flexibility for nested event-loop contexts, but for this integration test in a normal pytest process it is the safest default.
  • Impact: contributors with GEMINI_API_KEY can run the suite without hitting a framework-level async test failure unrelated to client correctness.

Practical gain / Why this matters

  • Improves test reliability and developer UX for real-key integration runs.
  • Removes an avoidable source of false-negative failures in local verification.
  • Keeps scope rollback-safe (single test change, no runtime package logic changed).

Testing

  • Reproduced failure before change:
    • scripts/clone_and_test.sh alexzhang13/rlm
    • Result included: FAILED tests/clients/test_gemini.py::TestGeminiClientIntegration::test_async_completion
  • Verified after change:
    • scripts/clone_and_test.sh alexzhang13/rlm
    • Result: 277 passed, 7 skipped

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant