Skip to content

test_configuring_a_connection_reaches_no_model_runtime asserts a process-global fact, so a full run fails wherever the extra is installed #501

Description

@JArmandoAnaya

tests/kernel/test_inference_connections.py::test_configuring_a_connection_reaches_no_model_runtime
ends with a process-global assertion:

assert not {"torch", "transformers", "huggingface_hub"} & set(sys.modules)

sys.modules belongs to the whole run, not to this test, so whether it passes is
decided by what ran before it. tests/inference sorts before tests/kernel, and
provider_for on a ready connection calls _extra.require(), which imports all
five modules of the extra. On a machine carrying local-inference the assertion
is therefore false by the time this test is collected.

Verified at b7dd21d with uv sync --locked --extra local-inference:

$ uv run pytest
FAILED tests/kernel/test_inference_connections.py::test_configuring_a_connection_reaches_no_model_runtime
1 failed, 3137 passed, 14 skipped in 201.40s

$ uv run pytest tests/kernel/test_inference_connections.py::test_configuring_a_connection_reaches_no_model_runtime
1 passed in 0.27s

So uv run pytest cannot be run green by any contributor who has the extra
installed — the one environment in which the assertion would actually mean
something.

CI is not affected, which is why this has gone unnoticed: the python job
installs no extra, so the set is empty by construction, and inference-smoke
runs a directory subset that excludes tests/kernel.

The claim itself is worth keeping — "creating a connection reaches no model
runtime" is the boundary the slice exists to draw. What it needs is an
order-independent home: a fresh interpreter, the way
tests/architecture/test_optional_runtime.py and test_kernel_purity.py already
ask this question. The AST half of the same test is order-independent and can
stay where it is.

Carried unfixed through the #486 and #491 bodies. No fix in the crumbs pass that
filed this — cf. #490 for why the with-extra job runs directories rather than
the suite.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtoolingDeveloper tooling: scripts, checks, local workflow

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions