Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set root to a temporary directory for unit tests #5833

Closed
wants to merge 1 commit into from

Conversation

lstein
Copy link
Collaborator

@lstein lstein commented Feb 29, 2024

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update
  • Community Node Submission

Have you discussed this change with the InvokeAI team?

  • Yes
  • Not needed

Have you updated all relevant documentation?

  • Yes
  • No

Description

Several unit tests were accessing the real InvokeAI root, leading to non-deterministic behavior. This PR adds a module-level pytest fixture called invokeai_root_dir which returns a path pointing to an initialized (mostly empty) root directory. This is then applied to the test_images unit test.

This PR also fixes an issue in the model manager’s sync_to_dir startup method, which was accessing the real root rather than the test root.

Related Tickets & Documents

  • Related Issue #
  • Closes #

QA Instructions, Screenshots, Recordings

Before applying this PR, insert an assert False into the first test in tests/app/routers/test_images.py. In the logged failures, you will see messages about the model manager traversing the real root directory. After applying this PR, the messages will show the model manager traversing the temporary root directory.

Merge Plan

Added/updated tests?

  • Yes
  • No : please replace this line with details on why tests
    have not been included

[optional] Are there any post deployment tasks we need to perform?

@github-actions github-actions bot added python PRs that change python files services PRs that change app services PythonTests labels Feb 29, 2024
@lstein
Copy link
Collaborator Author

lstein commented Feb 29, 2024

This PR is superseded by #5835

@lstein lstein closed this Feb 29, 2024
@lstein lstein deleted the fix-unit-test-root branch February 29, 2024 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
python PRs that change python files services PRs that change app services
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant