From 16b7e944f095a2d72729e6ed6cc945d710dc815e Mon Sep 17 00:00:00 2001 From: James Veitch <1722315+darth-veitcher@users.noreply.github.com> Date: Sat, 11 Jul 2026 18:02:57 +0100 Subject: [PATCH] fix(tests): make the import-compat proof order-independent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit beacon-reviewer caught a real gap: tests/test_comfyui_import_compat.py ERRORed (not passed) when run in isolation or under a file-sharded runner — the autouse _clear_ollama_caches fixture from conftest.py does `from comfydv._llm.ollama_provider import ...`, and this file was the one case where nothing had already bound `comfydv` in sys.modules correctly first, so it resolved to the wrong package. Only the full single-process suite happened to be green. Fixed by shadowing that fixture with a local no-op override scoped to this module: these tests exercise package import resolution itself, not OllamaProvider/ChatCompletion state, so there is nothing for the original fixture to reset here — and depending on it made the test order-dependent on an unrelated file's import order, which is exactly the kind of fragility this file exists to guard against. Verified: passes standalone (`pytest tests/test_comfyui_import_compat.py`) and as part of the full suite. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_0132ojafeazQ3ephcBejEWFj --- tests/test_comfyui_import_compat.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/test_comfyui_import_compat.py b/tests/test_comfyui_import_compat.py index 2a6cba3..406546f 100644 --- a/tests/test_comfyui_import_compat.py +++ b/tests/test_comfyui_import_compat.py @@ -24,8 +24,25 @@ import sys import textwrap from pathlib import Path +import pytest + REPO_ROOT = Path(__file__).parent.parent + +@pytest.fixture(autouse=True) +def _clear_ollama_caches(): + """Shadow conftest.py's autouse fixture of the same name for this module + only. That fixture's own setup does `from comfydv._llm.ollama_provider + import ...` — this file's tests are the exact reproduction of an + environment where `comfydv` resolving correctly can't be assumed (that's + the point of the file), so depending on it for an unrelated cache-reset + would make these tests order-dependent on whichever other test file + happens to import `comfydv` "the normal way" first in the session. These + tests touch no OllamaProvider/ChatCompletion state, so there is nothing + to reset.""" + yield + + _SUBPROCESS_SCRIPT = textwrap.dedent( """ import sys