test(lazy_imports): capture globals() before the star-import audit comprehension

The subprocess-level star-import audit called dir() inside a list comprehension,
which returns the comprehension's own scope on CPython 3.10/3.11/3.13/3.14 (and
only accidentally exposed the module globals on 3.12), so every name in
litellm.__all__ registered as missing and misc / Run tests failed on those
matrix cells. Snapshot globals() into a local before the comprehension so the
audit always sees the module-level bindings that from litellm import * just
created.

Co-authored-by: Krrish Dholakia <krrish-berri-2@users.noreply.github.com>
This commit is contained in:
Cursor Agent 2026-09-05 23:11:25 +00:00
parent a0c9095cfc
commit 9dfd3122dc
No known key found for this signature in database

View file

@ -408,7 +408,8 @@ def test_star_import_exports_public_api():
code = (
"from litellm import *\n"
"import litellm\n"
"missing = [n for n in litellm.__all__ if n not in dir()]\n"
"bound = globals()\n"
"missing = [n for n in litellm.__all__ if n not in bound]\n"
"assert not missing, missing[:20]\n"
"assert callable(completion) and callable(Router)\n"
)