diff --git a/main.py b/main.py index 4302e7709..25fb7db98 100644 --- a/main.py +++ b/main.py @@ -461,6 +461,9 @@ def cleanup_temp(): def setup_database(): if args.disable_assets: logging.info("Assets system disabled via --disable-assets; skipping database initialization and asset scanning.") + if args.enable_assets: + logging.info("--enable-assets is a deprecated no-op and does not override --disable-assets.") + disable_assets_routes() asset_seeder.disable() return try: diff --git a/tests-unit/assets_test/test_disabled_mode.py b/tests-unit/assets_test/test_disabled_mode.py index 95b9f16c2..cf93b676c 100644 --- a/tests-unit/assets_test/test_disabled_mode.py +++ b/tests-unit/assets_test/test_disabled_mode.py @@ -23,10 +23,12 @@ def _free_port() -> int: return s.getsockname()[1] -def _wait_assets_disabled(base: str, timeout: float = 90.0) -> None: +def _wait_assets_disabled(base: str, proc: subprocess.Popen, timeout: float = 90.0) -> None: start = time.time() last_err = None while time.time() - start < timeout: + if proc.poll() is not None: + raise RuntimeError(f"ComfyUI exited early with code {proc.returncode}") try: r = requests.get(base + "/api/assets", timeout=5) if r.status_code == 503: @@ -57,33 +59,42 @@ def disabled_comfy(tmp_path_factory: pytest.TempPathFactory): comfy_root = Path(__file__).resolve().parent.parent.parent port = _free_port() - proc = subprocess.Popen( - args=[ - sys.executable, - "main.py", - f"--base-directory={str(base_dir)}", - f"--database-url=sqlite:///{db_path}", - "--disable-assets", - "--listen", - "127.0.0.1", - "--port", - str(port), - "--cpu", - ], - stdout=out_log, - stderr=err_log, - cwd=str(comfy_root), - ) + try: + proc = subprocess.Popen( + args=[ + sys.executable, + "main.py", + f"--base-directory={str(base_dir)}", + f"--database-url=sqlite:///{db_path}", + "--disable-assets", + "--listen", + "127.0.0.1", + "--port", + str(port), + "--cpu", + ], + stdout=out_log, + stderr=err_log, + cwd=str(comfy_root), + ) + except Exception: + out_log.close() + err_log.close() + raise base_url = f"http://127.0.0.1:{port}" try: - _wait_assets_disabled(base_url) + _wait_assets_disabled(base_url, proc) yield base_url, db_path finally: if proc.poll() is None: with contextlib.suppress(Exception): proc.terminate() - proc.wait(timeout=15) + try: + proc.wait(timeout=15) + except subprocess.TimeoutExpired: + proc.kill() + proc.wait(timeout=15) out_log.close() err_log.close() diff --git a/tests-unit/execution_test/test_enrich_output.py b/tests-unit/execution_test/test_enrich_output.py index c60243f2f..ec1d6af38 100644 --- a/tests-unit/execution_test/test_enrich_output.py +++ b/tests-unit/execution_test/test_enrich_output.py @@ -54,9 +54,19 @@ def _call(output_ui, *, disable_assets=False, file_exists=True, register_result= class TestEnrichOutputWithAssets(unittest.TestCase): def test_disabled_returns_unchanged(self): + register_mock = MagicMock(return_value=_make_register_result()) + mocked = _mocked_modules(disable_assets=True, register_file_in_place=register_mock) output = {"images": [{"filename": "a.png", "subfolder": "", "type": "output"}]} - result = _call(output, disable_assets=True) + + with patch.dict("sys.modules", mocked), \ + patch("os.path.isfile", return_value=True): + import importlib + import comfy_execution.asset_enrichment as mod + importlib.reload(mod) + result = mod.enrich_output_with_assets(output) + self.assertNotIn("id", result["images"][0]) + register_mock.assert_not_called() def test_non_list_value_passed_through(self): output = {"text": "hello"}