Skip to content

fix(tests): make the IP-Adapter slow test runnable again - #9562

Open
Anai-Guo wants to merge 1 commit into
invoke-ai:mainfrom
Anai-Guo:fix-ip-adapter-test-fixtures
Open

fix(tests): make the IP-Adapter slow test runnable again#9562
Anai-Guo wants to merge 1 commit into
invoke-ai:mainfrom
Anai-Guo:fix-ip-adapter-test-fixtures

Conversation

@Anai-Guo

Copy link
Copy Markdown

Problem

tests/backend/ip_adapter/test_ip_adapter.py::test_ip_adapter_unet_patch cannot
run. It is @pytest.mark.slow, which the default
addopts = ... -m "not slow" excludes, so nothing surfaces it.

Three things are wrong:

  1. It requests a model_installer fixture that does not exist anywhere in
    the tree.
  2. It calls install_and_load_model(model_installer=...), but that parameter
    has been model_manager since the model-manager refactor
    (invokeai/backend/util/test_utils.py:24).
  3. It requests torch_device, defined at
    invokeai/backend/util/test_utils.py:15 but not imported into any
    conftest
    , so pytest cannot resolve that one either.

tests/conftest.py line 5 still says

# We import the model_installer and torch_device fixtures here so that they can be used by all tests.

— but neither import is actually there any more.

Fix

  • use mm2_model_manager (already star-imported into tests/conftest.py via
    tests.backend.model_manager.model_manager_fixtures) and pass it as
    model_manager=
  • import torch_device in tests/conftest.py. That is what the comment already
    claims, and the same file documents this as the convention for fixtures that
    trip F401/F811 — importing it in the test module instead produces two F811s
    against build_dummy_sd15_unet_input(torch_device) and the test signature
  • drop model_installer from that comment, and fix the docstring Args: entry
    in install_and_load_model, which still calls the parameter
    mm2_model_manager

Verification

The test downloads models, so I have not run it. What is checked statically —
signature parsed out of test_utils.py on main, fixtures grepped from the
actual files rather than code search:

install_and_load_model (model_manager, model_path_id_or_url, model_name, base_model, model_type, submodel_type=None)
  main     model_installer=... -> TypeError: install_and_load_model() got an unexpected keyword argument 'model_installer'
  this PR  model_manager=...   -> binds OK

  def model_installer(...)   defined in tests/conftest.py: False
  def mm2_model_manager(...) defined in tests/backend/model_manager/model_manager_fixtures.py: True
  def torch_device(...)      defined in invokeai/backend/util/test_utils.py: True

  conftest imports torch_device: False
  conftest defines model_installer: False
  conftest still names model_installer in a comment: True

ruff check and ruff format --check with the repo pyproject.toml report
exactly the same results on the patched files as on main — no new findings.

Happy to also just delete the test instead if it is considered dead; it looked
worth keeping since -m "slow" is a documented way to run it.

🤖 Generated with Claude Code

test_ip_adapter_unet_patch asks for a `model_installer` fixture that no longer
exists and passes install_and_load_model(model_installer=...), whose parameter
has been `model_manager` since the model-manager refactor. It also asks for
`torch_device`, which is defined in invokeai/backend/util/test_utils.py but is
not imported into any conftest, so pytest cannot resolve it either.

- use the `mm2_model_manager` fixture (already star-imported into
  tests/conftest.py) and pass it as `model_manager=`
- import `torch_device` in tests/conftest.py, which is what the comment at the
  top of that file already claims happens, and is the convention the file
  documents for fixtures that trip F401/F811
- drop `model_installer` from that comment and fix the stale `mm2_model_manager`
  arg name in the install_and_load_model docstring

The test is @pytest.mark.slow, excluded by the default `-m "not slow"`, which is
why this went unnoticed.
@github-actions github-actions Bot added python PRs that change python files backend PRs that change backend files python-tests PRs that change python tests labels Aug 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend PRs that change backend files python PRs that change python files python-tests PRs that change python tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant