1 Commits
Author SHA1 Message Date
Gregory RichardandClaude Opus 5.5 64cd60dd5d fix: tests import the pack without ComfyUI
pytest imports the pack root while collecting, before any fixture runs, so the
comfy_api stand-in is installed when conftest loads and __init__ falls back to
an absolute import outside a package, as in WarpPipe.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 23:15:01 +01:00
2 changed files with 17 additions and 9 deletions
+5 -1
View File
@@ -1,3 +1,7 @@
from .realism import comfy_entrypoint
if __package__:
from .realism import comfy_entrypoint
else:
# pytest imports the pack root as a plain module
from realism import comfy_entrypoint
__all__ = ["comfy_entrypoint"]
+12 -8
View File
@@ -43,16 +43,20 @@ io = types.SimpleNamespace(
)
# installed at import time: pytest imports the pack's __init__.py while collecting, before any fixture runs
_latest = types.ModuleType("comfy_api.latest")
_latest.ComfyExtension = type("ComfyExtension", (), {})
_latest.io = io
_comfy_api = types.ModuleType("comfy_api")
_comfy_api.__path__ = []
_comfy_api.latest = _latest
sys.modules.setdefault("comfy_api", _comfy_api)
sys.modules.setdefault("comfy_api.latest", _latest)
sys.path.insert(0, str(PROJECT_ROOT))
@pytest.fixture(scope="session")
def realism():
latest = types.ModuleType("comfy_api.latest")
latest.ComfyExtension = type("ComfyExtension", (), {})
latest.io = io
comfy_api = types.ModuleType("comfy_api")
comfy_api.__path__ = []
comfy_api.latest = latest
sys.modules["comfy_api"] = comfy_api
sys.modules["comfy_api.latest"] = latest
spec = importlib.util.spec_from_file_location("realism", PROJECT_ROOT / "realism.py")
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)