fix(tests): make the import-compat proof order-independent
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 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0132ojafeazQ3ephcBejEWFj
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
36e2cd123c
commit
16b7e944f0
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user